/* === БОЕВАЯ СИСТЕМА (HoMM3-style) === */
#battle-modal .battle-content {
    width: 90vw;
    max-width: 1100px;
    height: 85vh;
    max-height: 700px;
    padding: 0;
    background: linear-gradient(135deg, #1a0a2e 0%, #2d1b4e 100%);
    border: 3px solid #c9a84c;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    color: #e8d5b0;
    font-family: 'Fredoka', sans-serif;
}

.battle-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background: linear-gradient(90deg, #2a1a3e, #3d2a5e);
    border-bottom: 2px solid #c9a84c;
}

.battle-header h2 {
    margin: 0;
    font-size: 22px;
    color: #ffd700;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.4);
}

.battle-header-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

#close-battle-btn {
    background: none;
    border: 2px solid #c9a84c;
    color: #c9a84c;
    font-size: 20px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
}

#close-battle-btn:hover {
    background: rgba(201, 168, 76, 0.2);
    color: #fff;
}

.battle-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.battle-field-wrapper {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0d0618;
    min-width: 0;
}

#battle-canvas {
    width: 100%;
    height: 100%;
    display: block;
    cursor: pointer;
}

.battle-sidebar {
    width: 280px;
    min-width: 280px;
    display: flex;
    flex-direction: column;
    background: rgba(20, 10, 40, 0.9);
    border-left: 2px solid #c9a84c;
}

.battle-log {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    border-bottom: 1px solid #3a2a5a;
}

.battle-log-title,
.units-panel-title {
    padding: 8px 12px;
    font-size: 14px;
    font-weight: 600;
    color: #c9a84c;
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid #3a2a5a;
}

#battle-log-entries {
    flex: 1;
    overflow-y: auto;
    padding: 8px 12px;
    font-size: 12px;
    line-height: 1.6;
    color: #d4c4a8;
}

#battle-log-entries div {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding: 2px 0;
}

.battle-units-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#battle-unit-cards {
    flex: 1;
    overflow-y: auto;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.battle-unit-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
    border: 2px solid transparent;
}

.battle-unit-card:hover {
    background: rgba(255, 255, 255, 0.1);
}

.battle-unit-card.selected {
    border-color: #ffd700;
    background: rgba(255, 215, 0, 0.1);
}

.battle-unit-card.dead {
    opacity: 0.4;
    cursor: default;
}

.battle-unit-card.enemy-unit {
    border-color: rgba(255, 50, 50, 0.3);
}

.battle-unit-card .unit-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.battle-unit-card .unit-info {
    flex: 1;
    min-width: 0;
}

.battle-unit-card .unit-name {
    font-size: 13px;
    font-weight: 600;
    color: #e8d5b0;
}

.battle-unit-card .unit-stats {
    font-size: 11px;
    color: #aaa;
}

.battle-unit-card .hp-bar-outer {
    width: 100%;
    height: 6px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 3px;
    margin-top: 3px;
    overflow: hidden;
}

.battle-unit-card .hp-bar-inner {
    height: 100%;
    background: linear-gradient(90deg, #e74c3c, #2ecc71);
    border-radius: 3px;
    transition: width 0.3s;
}

.battle-unit-card .hp-text {
    font-size: 10px;
    color: #ccc;
    margin-left: auto;
    white-space: nowrap;
}

.battle-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    padding: 8px;
    background: rgba(0, 0, 0, 0.3);
    border-top: 1px solid #3a2a5a;
}

.battle-action-btn {
    flex: 1;
    min-width: calc(50% - 5px);
    padding: 8px 4px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid #5a4a7a;
    color: #e8d5b0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-family: 'Fredoka', sans-serif;
    transition: all 0.2s;
    text-align: center;
}

.battle-action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: #c9a84c;
}

.battle-action-btn.primary {
    min-width: 100%;
    background: linear-gradient(135deg, #3d2a5e, #5a3a8e);
    border-color: #c9a84c;
    color: #ffd700;
}

.battle-action-btn.primary:hover {
    background: linear-gradient(135deg, #5a3a8e, #7a5aae);
}

#battle-prompt-modal .modal-content {
    max-width: 360px;
    text-align: center;
    background: linear-gradient(135deg, #1a0a2e, #2d1b4e);
    border: 2px solid #c9a84c;
    color: #e8d5b0;
}

#battle-prompt-modal h3 {
    color: #ffd700;
    font-size: 24px;
    margin-bottom: 10px;
}

#battle-prompt-modal .battle-prompt-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 20px;
}

#battle-prompt-modal .battle-prompt-btn {
    padding: 10px 30px;
    border: 2px solid #c9a84c;
    border-radius: 8px;
    font-family: 'Fredoka', sans-serif;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s;
}

#battle-prompt-modal .battle-prompt-btn.accept {
    background: linear-gradient(135deg, #2d7a3a, #4a9a5a);
    color: #fff;
}

#battle-prompt-modal .battle-prompt-btn.accept:hover {
    background: linear-gradient(135deg, #4a9a5a, #6aba7a);
}

#battle-prompt-modal .battle-prompt-btn.decline {
    background: linear-gradient(135deg, #7a2a2a, #9a4a4a);
    color: #fff;
}

#battle-prompt-modal .battle-prompt-btn.decline:hover {
    background: linear-gradient(135deg, #9a4a4a, #ba6a6a);
}

/* Анимация появления битвы */
@keyframes battleModalIn {
    from { transform: scale(0.8) rotateY(90deg); opacity: 0; }
    to { transform: scale(1) rotateY(0); opacity: 1; }
}

#battle-modal .battle-content {
    animation: battleModalIn 0.4s ease-out;
}

@media (max-width: 768px) {
    #battle-modal .battle-content {
        width: 100vw;
        height: 100vh;
        max-width: none;
        max-height: none;
        border-radius: 0;
        border: none;
    }
    .battle-sidebar {
        width: 200px;
        min-width: 200px;
    }
    .battle-action-btn {
        font-size: 10px;
        padding: 6px 2px;
    }
}

/* Мобильная битва — портрет (узкие экраны) */
@media (max-width: 480px) {
    #battle-modal .battle-content {
        width: 100vw;
        height: 100vh;
        max-width: none;
        max-height: none;
        border-radius: 0;
        border: none;
    }
    .battle-header {
        padding: 6px 12px;
        flex-shrink: 0;
    }
    .battle-header h2 {
        font-size: 16px;
    }
    .battle-header-info {
        gap: 8px;
    }
    #close-battle-btn {
        width: 30px;
        height: 30px;
        font-size: 16px;
    }
    .battle-body {
        flex-direction: column;
        flex: 1;
        overflow: hidden;
    }
    .battle-field-wrapper {
        flex: 1;
        min-height: 0;
        width: 100%;
    }
    #battle-canvas {
        width: 100%;
        height: 100%;
    }
    .battle-sidebar {
        width: 100%;
        min-width: unset;
        max-height: 40%;
        flex-direction: row;
        flex-wrap: wrap;
        overflow-y: auto;
        border-left: none;
        border-top: 2px solid #c9a84c;
        padding: 6px;
    }
    .battle-log {
        width: 100%;
        max-height: 120px;
        margin-bottom: 4px;
    }
    .battle-log #battle-log-entries {
        font-size: 11px;
    }
    .battle-units-panel {
        width: 100%;
    }
    .battle-units-panel #battle-unit-cards {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
    }
    .battle-unit-card {
        padding: 4px 8px;
        font-size: 11px;
        min-width: 70px;
        flex: 1;
    }
    .battle-unit-card .unit-icon {
        font-size: 16px;
        width: 24px;
        height: 24px;
    }
    .battle-unit-card .unit-name {
        font-size: 10px;
    }
    .battle-unit-card .unit-stats {
        font-size: 9px;
    }
    .battle-actions {
        width: 100%;
        display: flex;
        gap: 6px;
        justify-content: stretch;
    }
    .battle-action-btn {
        flex: 1;
        font-size: 11px;
        padding: 6px 8px;
        text-align: center;
    }
    /* Подтверждение битвы на мобильных */
    #battle-prompt-modal .modal-content {
        max-width: 85vw;
        padding: 20px 15px;
    }
    #battle-prompt-modal h3 {
        font-size: 18px;
    }
    #battle-prompt-modal .battle-prompt-btn {
        padding: 10px 20px;
        font-size: 15px;
    }
}

