/* --- Combat Screen Layout --- */

.combat-container {
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    padding-bottom: 80px;
    /* Nav height */
}

/* 1. Enemy Section (Top) */
.enemy-section {
    flex: 0 0 35%;
    padding: 10px;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.6), transparent);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.enemy-row {
    display: flex;
    flex-direction: column;
    /* Vertical list for text-based enemies */
    gap: 8px;
    padding: 5px;
    overflow-y: auto;
}

.enemy-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    padding: 8px 12px;
    border-radius: 4px;
    border-left: 3px solid transparent;
    transition: all 0.2s;
    position: relative;
    /* For popups */
}

.enemy-card.active {
    background: rgba(255, 50, 50, 0.1);
    border-left-color: var(--danger);
}

.enemy-card.dead {
    opacity: 0.4;
    filter: grayscale(1);
    border-left-color: #555;
    background: transparent;
    /* Maintain layout */
    display: flex;
}

/* Text-based enemy representation */
.enemy-info-text {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.enemy-name {
    font-size: 14px;
    color: var(--text-main);
    font-weight: 500;
}

.enemy-hp-wrapper {
    width: 60%;
    margin-left: 10px;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* 2. Combat Log (Center) */
.combat-log-section {
    flex: 0 0 150px;
    /* Fixed height approx 10 lines */
    background: rgba(0, 0, 0, 0.5);
    margin: 5px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 10px;
    overflow-y: auto;
    font-family: 'Inter', monospace;
    font-size: 11px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    scrollbar-width: thin;
}

.log-entry {
    color: var(--text-muted);
    line-height: 1.4;
    animation: fadeIn 0.3s;
    flex-shrink: 0;
}

.log-turn {
    text-align: center;
    color: var(--text-dim);
    border-bottom: 1px dashed rgba(255, 255, 255, 0.1);
    margin: 5px 0;
    font-size: 10px;
    flex-shrink: 0;
}

/* 3. Ally Section (Bottom) */
.ally-section {
    flex: 1;
    /* Take remaining space */
    display: flex;
    justify-content: space-around;
    padding: 10px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9), transparent);
    gap: 8px;
    align-items: flex-end;
    /* Align to bottom */
}

.ally-card {
    width: 23%;
    height: 100%;
    /* Fill available space */
    max-height: 160px;
    /* Max height limit */
    background: rgba(20, 22, 30, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    padding: 0;
    /* Removing padding to let image fill */
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: relative;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s, box-shadow 0.2s;
    overflow: hidden;
}

.ally-card.active-turn {
    border-color: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
    transform: translateY(-2px);
}

.ally-card.dead {
    filter: grayscale(1) brightness(0.4);
    border-color: #444;
}

.ally-top {
    position: relative;
    width: 100%;
    flex: 1;
    /* Image area takes available space */
    display: block;
    margin-bottom: 0;
}

.ally-face {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    opacity: 0.8;
}

.ally-info {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.95), transparent);
    padding: 10px 4px 2px;
}

.ally-name {
    font-size: 11px;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: bold;
    text-align: center;
    text-shadow: 0 1px 3px black;
}

/* Bars Section - Pushed to bottom of card */
.ally-bars {
    padding: 4px;
    background: rgba(0, 0, 0, 0.5);
    flex-shrink: 0;
}

.bar-container {
    height: 5px;
    /* Thicker */
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
    position: relative;
    width: 100%;
    margin-bottom: 2px;
}

.bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s;
}

.hp-fill {
    background: var(--success);
}

.mp-fill {
    background: var(--primary);
}

.action-text {
    font-size: 8px;
    text-align: center;
    color: var(--gold);
    height: 10px;
    overflow: hidden;
}

/* --- Visual Effects --- */

/* Damage Popup */
.damage-popup {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-weight: bold;
    font-size: 18px;
    text-shadow: 0 2px 4px #000, 0 0 5px #000;
    pointer-events: none;
    z-index: 100;
    animation: popupFloat 0.8s forwards ease-out;
}

.damage-popup.critical {
    color: var(--gold);
    font-size: 24px;
    text-shadow: 0 0 10px orange;
}

@keyframes popupFloat {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 0;
    }

    20% {
        transform: translate(-50%, -80%) scale(1.2);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -150%) scale(1);
        opacity: 0;
    }
}

/* Flash Effect */
@keyframes flashRed {
    0% {
        background-color: rgba(255, 0, 0, 0.5);
    }

    100% {
        background-color: transparent;
    }
}

.flash-hit {
    animation: flashRed 0.3s ease-out;
}

/* Victory Modal Overlay */
.battle-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s;
}

.battle-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.victory-title {
    font-size: 32px;
    color: var(--gold);
    text-transform: uppercase;
    font-weight: 800;
    margin-bottom: 20px;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
    animation: var(--anim-zoom);
}

.defeat-title {
    font-size: 32px;
    color: var(--danger);
    text-transform: uppercase;
    font-weight: 800;
    margin-bottom: 20px;
    text-shadow: 0 0 20px rgba(255, 50, 50, 0.5);
    animation: var(--anim-zoom);
}

.overlay-btn {
    padding: 10px 30px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: #fff;
    cursor: pointer;
    font-family: inherit;
    border-radius: var(--radius-sm);
    transition: background 0.2s;
}

.overlay-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
}