.battle-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 15px;
    width: 900px;
    max-width: 94vw;
    box-sizing: border-box;
    overflow: hidden;
}

.battle-main {
    display: flex;
    flex-direction: row;
    gap: 16px;
    height: 460px;
}

.battle-arena {
    position: relative;
    flex: 2;
    min-width: 0;
    height: 460px;
    border-radius: 12px;
    overflow: hidden;
    background: #0a0a14;
    border: 1px solid rgba(78, 205, 196, 0.18);
}

.battle-canvas {
    display: block;
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.battle-fx-anchor {
    position: absolute;
    top: 52%;
    width: 1px;
    height: 1px;
    pointer-events: none;
}
.battle-fx-anchor-player { left: 26%; }
.battle-fx-anchor-enemy { left: 74%; }

/* Controls bar */
.battle-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    flex-wrap: wrap;
    gap: 8px;
    flex-shrink: 0;
}

.battle-speed-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.battle-action-buttons {
    display: flex;
    gap: 10px;
}

.battle-speed-btn {
    padding: 8px 16px;
    border: 2px solid var(--ui-teal);
    background: transparent;
    color: var(--ui-teal);
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
}

.battle-speed-btn:hover { background: rgba(78, 205, 196, 0.2); }
.battle-speed-btn.active { background: var(--ui-teal); color: #1a1a2e; }
.battle-speed-btn.locked {
    opacity: 0.4;
    cursor: not-allowed;
    border-color: #666;
    color: #666;
}
.battle-speed-btn.locked:hover { background: transparent; }

.battle-defend-btn {
    padding: 8px 16px;
    border: 2px solid var(--ui-purple);
    background: transparent;
    color: var(--ui-purple);
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
}
.battle-defend-btn:hover { background: rgba(155, 89, 182, 0.2); }
.battle-defend-btn.active { background: var(--ui-purple); color: #1a1a2e; }

.battle-leave-btn {
    padding: 8px 20px;
    border: 2px solid var(--ui-red);
    background: transparent;
    color: var(--ui-red);
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
}
.battle-leave-btn:hover { background: rgba(231, 76, 60, 0.2); }

/* Battle log */
.battle-log-container {
    background: rgba(0, 0, 0, 0.4);
    border-radius: 8px;
    padding: 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 160px;
    max-width: 300px;
    height: 460px;
    overflow: hidden;
}

.battle-log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.battle-log-title { font-weight: bold; color: #888; }

.battle-log-toggle {
    padding: 3px 10px;
    border: 1px solid #666;
    background: transparent;
    color: #888;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.8em;
}
.battle-log-toggle:hover { background: rgba(255, 255, 255, 0.1); }

.battle-log-content {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    font-size: 0.9em;
    line-height: 1.6;
}

.battle-log-entry { padding: 2px 0; color: #aaa; }
.battle-log-entry.player-action { color: var(--ui-teal); }
.battle-log-entry.enemy-action { color: var(--ui-red); }
.battle-log-entry.crit { color: var(--ui-gold); }
.battle-log-entry.effect { color: var(--ui-purple); }
.battle-log-entry.heal { color: #2ecc71; }

/* Soul weapon indicators */
.soul-weapon-indicators {
    display: flex;
    gap: 10px;
    justify-content: center;
    padding: 8px;
    background: rgba(168, 85, 247, 0.1);
    border-radius: 8px;
    margin-bottom: 10px;
}

.soul-weapon-indicator { flex: 1; max-width: 150px; text-align: center; }

.sw-name {
    font-size: 11px;
    color: #a855f7;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sw-cooldown-bar { height: 6px; background: #333; border-radius: 3px; overflow: hidden; }
.sw-cooldown-fill { height: 100%; background: linear-gradient(90deg, #a855f7, #06b6d4); }

/* Result overlay */
.battle-result-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.82);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 20px;
    z-index: 10;
    border-radius: 12px;
}

.battle-result-text {
    font-size: 2.5em;
    font-weight: bold;
    text-shadow: 0 0 20px currentColor;
}
.battle-result-text.victory { color: var(--ui-teal); }
.battle-result-text.defeat { color: var(--ui-red); }

.battle-result-rewards { text-align: center; color: var(--ui-gold); font-size: 1.2em; }

.battle-continue-btn {
    padding: 12px 40px;
    border: 2px solid var(--ui-teal);
    background: var(--ui-teal);
    color: #1a1a2e;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    font-size: 1.1em;
    transition: all 0.2s;
}
.battle-continue-btn:hover { background: #44a6a0; border-color: #44a6a0; }

/* Mobile */
.battle-mobile-top-bar { display: none; }
.battle-mobile-menu-btn {
    display: none;
    padding: 4px 12px;
    background: rgba(78, 205, 196, 0.15);
    border: 2px solid var(--ui-teal);
    border-radius: 6px;
    color: var(--ui-teal);
    font-weight: bold;
    font-size: 0.75em;
    cursor: pointer;
}
.battle-mobile-panel { display: contents; }

@media (max-width: 1000px) {
    .battle-container { width: 100%; max-width: 100vw; }
    .battle-main { flex-direction: column; height: auto; }
    .battle-arena { flex: none; height: 340px; }
    .battle-log-container { max-width: none; height: 160px; }
}

@media (max-width: 768px), (max-height: 500px) and (pointer: coarse) {
    .battle-container { padding: 6px; gap: 6px; }
    .battle-arena { height: 42vh; }
    .battle-speed-btn, .battle-defend-btn, .battle-leave-btn { padding: 4px 8px; font-size: 0.72em; }
    #battleModal .modal-inner {
        padding: 6px !important;
        border-width: 1px !important;
        width: 100% !important;
        max-width: 100vw !important;
        max-height: 100vh !important;
    }
    .battle-mobile-top-bar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        margin-bottom: 4px;
    }
    .battle-mobile-menu-btn { display: block; }
    .battle-mobile-panel { display: none; flex-direction: column; gap: 8px; }
    .battle-mobile-panel.open { display: flex; }
    .battle-log-container { display: none; }
    .battle-mobile-panel.open ~ .battle-main .battle-log-container { display: flex; }
}
