/* Unit Selection & Slots */
.slot-area {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(8, 1fr);
    gap: 2px;
    padding: 4px;
    z-index: 5;
    background: rgba(0, 0, 0, 0.2);
    box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.5);
    margin-top: 148px;
}

.card-slot {
    position: relative;
    box-sizing: border-box;
    border: none; 
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.card-slot:hover {
    background: radial-gradient(circle, rgba(255, 215, 0, 0.1) 0%, transparent 80%);
    transform: scale(1.05);
}

.card-slot.occupied {
    border: none;
    background: transparent;
    box-shadow: none;
}

.card-slot.drag-over {
    background: radial-gradient(circle, rgba(0, 255, 0, 0.2) 0%, transparent 70%);
    border: 1px solid #00ff00;
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.3);
}

/* Units */
.unit {
    position: relative;
    width: 80%;
    height: 80%;
    border-radius: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer; 
    z-index: 15;
    font-size: 18px;
    pointer-events: auto; 
    background: transparent;
    border: none;
    text-shadow: 
        -1px -1px 0 #000,  
         1px -1px 0 #000,
        -1px  1px 0 #000,  
         1px  1px 0 #000;
}

.unit.dragging {
    opacity: 0.5;
}

.unit.move-ready {
    animation: movePulse 0.5s infinite alternate;
}

@keyframes movePulse {
    from { opacity: 0.7; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1.05); }
}

.unit.selected {
    transform: scale(1.1);
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.unit.apprentice { color: transparent !important; text-shadow: none !important; font-size: 0; }

/* Unit Overlay Buttons */
.unit-overlay-btn {
    position: absolute;
    width: 36px; /* Increased from 12px */
    height: 36px; /* Increased from 12px */
    background: rgba(0, 0, 0, 0.9);
    border-radius: 50%;
    display: none;
    justify-content: center;
    align-items: center;
    font-size: 20px; /* Increased from 8px */
    cursor: pointer;
    z-index: 30;
    border: 2px solid #fff;
    pointer-events: auto;
    transition: transform 0.1s, background 0.2s, box-shadow 0.2s;
}

.unit.selected .unit-overlay-btn {
    display: flex;
}

.unit-overlay-btn:hover {
    transform: scale(1.2);
    background: rgba(40, 40, 40, 1);
    box-shadow: 0 0 15px #fff;
    z-index: 31;
}

.promote-btn { top: -24px; left: -24px; border-color: #00ff00; color: #00ff00; }
.promote-10 { top: -20px; left: -20px; border-color: #ff4500; color: #ff4500; }
.promote-12 { top: -32px; left: calc(50% - 18px); border-color: #00e5ff; color: #00e5ff; }
.promote-2 { top: -20px; right: -20px; border-color: #ffd700; color: #ffd700; }
.promote-btn-right { top: -24px; right: -24px; border-color: #ffd700; color: #ffd700; }
.sell-btn { bottom: -24px; left: calc(50% - 18px); border-color: #ff0000; color: #ff0000; background: rgba(139, 0, 0, 0.9); box-shadow: 0 0 10px #ff0000; }

.sell-btn:hover { background: #ff0000; color: #fff; box-shadow: 0 0 20px #ff0000, 0 0 40px #ff4500; transform: scale(1.2); }

/* Cooldown */
.cooldown-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    border-radius: 4px;
    background: conic-gradient(rgba(0, 0, 0, 0.3) 0deg, transparent 0deg);
    pointer-events: none;
    z-index: 5;
}

/* Tower Cards */
.tower-card {
    pointer-events: auto; 
    width: 100%;
    height: 100%;
    max-height: 165px;
    background: linear-gradient(135deg, #003366, #001133);
    border: 6px solid #00e5ff;
    border-radius: 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer; 
    box-shadow: 0 0 30px rgba(0, 229, 255, 0.3);
    color: #00e5ff;
    font-size: 30px;
    user-select: none;
    z-index: 100;
    box-sizing: border-box;
    text-align: center;
}

.tower-card.locked {
    filter: grayscale(100%) brightness(0.6);
    opacity: 0.7;
    cursor: not-allowed;
    border-color: #444;
    box-shadow: none;
    position: relative;
}

#purge-card {
    border-color: #9400d3 !important;
    color: #9400d3 !important;
    box-shadow: 0 0 30px rgba(148, 0, 211, 0.2);
    transition: all 0.2s;
}

#purge-card:hover {
    box-shadow: 0 0 45px rgba(148, 0, 211, 0.5);
    background: linear-gradient(135deg, #2a0052, #000);
}

/* Unit Info Panel */
#unit-info {
    background: linear-gradient(145deg, #1a1a00, #000);
    border: 3px solid #ffd700;
    border-radius: 12px;
    padding: 12px 18px;
    font-size: 27px;
    color: #fff;
    text-align: center;
    flex: 1;
    overflow-y: auto;
    box-shadow: inset 0 0 30px rgba(255, 215, 0, 0.2), 0 0 30px rgba(255, 215, 0, 0.1);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    scrollbar-width: none;
}

#unit-info::-webkit-scrollbar { display: none; }

.info-default-text {
    font-family: 'Cinzel', serif;
    font-weight: bold;
    font-size: 42px;
    color: #ffd700;
    text-shadow: 0 0 15px #ffd700, 0 0 30px #ff8c00, 0 0 45px #ff0000;
    letter-spacing: 3px;
    line-height: 1.2;
    animation: divinePulse 3s infinite alternate;
    text-transform: uppercase;
}

.divine-glow {
    color: #ffd700;
    text-shadow: 0 0 30px #ffd700, 0 0 60px #ff8c00;
    font-weight: bold;
    letter-spacing: 6px;
    animation: divinePulse 2s infinite alternate;
}

/* Unit Classes (Visual hints, mostly handled by canvas now) */
.unit.abyss {
    box-shadow: 0 0 30px #9400d3;
    animation: abyssPulse 2s infinite alternate;
}

@keyframes abyssPulse {
    from { box-shadow: 0 0 15px #4b0082; transform: scale(1); }
    to { box-shadow: 0 0 30px #9400d3, 0 0 10px #fff; transform: scale(1.05); }
}

/* Bestiary & Tree */
#bestiary-tab {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); 
    gap: 20px;
    padding: 180px 20px 40px 20px; 
    width: 100%;
    box-sizing: border-box;
}

.bestiary-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, #1a1a1a, #0a0a0a);
    padding: 20px;
    border-radius: 12px;
    border: 2px solid #333;
    text-align: center;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    aspect-ratio: 3/4;
    box-shadow: 0 10px 20px rgba(0,0,0,0.5);
}

.bestiary-item:hover {
    border-color: #ffd700;
    transform: translateY(-10px);
    box-shadow: 0 15px 30px rgba(255, 215, 0, 0.2);
}

.bestiary-item.locked {
    filter: grayscale(100%) brightness(0.5);
    border-style: dashed;
    opacity: 0.6;
}

.bestiary-icon {
    font-size: 64px;
    margin-bottom: 15px;
    filter: drop-shadow(0 0 10px rgba(255,255,255,0.2));
}

.bestiary-name {
    font-size: 24px;
    font-weight: bold;
    color: #eee;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.bestiary-stats {
    font-size: 18px;
    color: #888;
    background: rgba(0,0,0,0.3);
    padding: 5px 10px;
    border-radius: 20px;
    width: 100%;
    box-sizing: border-box;
}

.custom-tooltip {
    visibility: hidden;
    width: 390px;
    background-color: rgba(15, 15, 15, 0.95);
    color: #eee;
    text-align: center;
    border-radius: 18px;
    padding: 18px;
    position: absolute;
    z-index: 1000;
    bottom: 115%; 
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.3s, visibility 0.3s;
    border: 3px solid #ffd700;
    font-size: 24px;
    line-height: 1.3;
    pointer-events: none;
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.8), 0 0 30px rgba(255, 215, 0, 0.2);
}

.custom-tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -15px;
    border-width: 15px;
    border-style: solid;
    border-color: #ffd700 transparent transparent transparent;
}

.bestiary-item:hover .custom-tooltip,
.unit-node:hover .custom-tooltip {
    visibility: visible;
    opacity: 1;
}

.tree-node { display: flex; flex-direction: column; align-items: center; gap: 30px; }
.tree-row { display: flex; justify-content: center; gap: 60px; margin-bottom: 90px; position: relative; }

.unit-node {
    padding: 15px 30px;
    border: 3px solid #555;
    border-radius: 12px;
    background: #222;
    font-size: 30px;
    text-align: center;
    min-width: 240px;
    cursor: help;
}

.unit-node.locked { filter: grayscale(100%); opacity: 0.3; background: #000; border-color: #333; color: #444; }
.unit-node.tier1 { border-color: #00e5ff; }
.unit-node.tier2 { border-color: #9370db; }
.unit-node.tier3 { border-color: #ffd700; }
.unit-node.tier4 { border-color: #9400d3; }
