/* ====== COMBAT 3-COLUMN LAYOUT ====== */
.combat-3col {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(0, 3fr) minmax(180px, 1fr);
    width: 100%;
    height: 100%;
    gap: 0;
    overflow: hidden;
}

/* Left: Initiative */
.combat-left {
    background: rgba(14, 14, 14, 0.95);
    border-right: 1px solid #2a2d35;
    display: flex;
    flex-direction: column;
    padding: 12px;
    overflow-y: auto;
}

/* Center: Map + Log */
.combat-center {
    display: flex;
    flex-direction: column;
    background: rgba(10, 10, 14, 0.9);
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

/* Right: Stats + Actions */
.combat-right {
    background: rgba(14, 14, 14, 0.95);
    border-left: 1px solid #2a2d35;
    display: flex;
    flex-direction: column;
    padding: 12px;
    overflow-y: auto;
}

/* ====== BATTLEFIELD GRID ====== */
.combat-battlefield-wrap {
    flex: 1 1 50%;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 8px;
}
.combat-battlefield-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 8px 6px 8px;
    font-size: 13px;
    font-weight: 600;
    color: #8a8fa8;
}
.combat-battlefield-header .material-symbols-outlined { font-size: 16px; }
.combat-round-badge {
    margin-left: auto;
    background: #1e2030;
    color: #e0e0e0;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    border: 1px solid #333;
}
.combat-battlefield {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: auto;
    padding: 4px;
}
.combat-grid {
    display: grid;
    gap: 1px;
    background: #0a0b0f;
    border: 2px solid #333;
    border-radius: 6px;
    padding: 2px;
}
.combat-cell {
    width: 28px;
    height: 28px;
    background: #1a1c24;
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s;
}
.combat-cell:hover { background: #252836; }
.combat-cell.wall {
    background: #0d0e12;
    cursor: default;
    box-shadow: inset 0 0 8px rgba(0,0,0,0.8);
}
.combat-cell.reachable {
    background: rgba(79, 195, 247, 0.2);
    box-shadow: inset 0 0 0 1px rgba(79, 195, 247, 0.4);
}
.combat-cell.reachable:hover {
    background: rgba(79, 195, 247, 0.35);
    box-shadow: inset 0 0 0 2px rgba(79, 195, 247, 0.6);
}
.combat-cell.attack-target {
    background: rgba(244, 67, 54, 0.25);
    box-shadow: inset 0 0 0 2px rgba(244, 67, 54, 0.6);
    animation: pulse-red 1s infinite;
}
@keyframes pulse-red {
    0%, 100% { box-shadow: inset 0 0 0 2px rgba(244, 67, 54, 0.6); }
    50% { box-shadow: inset 0 0 0 2px rgba(244, 67, 54, 0.9); }
}
.combat-cell.player-cell { background: rgba(79, 195, 247, 0.3); }
.combat-cell.enemy-cell { background: rgba(244, 67, 54, 0.3); }
.combat-token {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
    border: 2px solid rgba(255,255,255,0.3);
    z-index: 2;
}
.combat-token.player-token {
    border-color: #4fc3f7;
    box-shadow: 0 0 8px rgba(79, 195, 247, 0.5);
}
.combat-token.enemy-token {
    border-color: #ff6666;
    box-shadow: 0 0 6px rgba(255, 100, 100, 0.4);
}
.combat-battlefield-hint {
    text-align: center;
    padding: 4px;
    font-size: 11px;
    color: #555;
    font-style: italic;
}

/* ====== BATTLE LOG ====== */
.combat-log-panel {
    flex: 0 0 35%;
    display: flex;
    flex-direction: column;
    background: rgba(10, 10, 14, 0.6);
    border-top: 1px solid #2a2d35;
    min-height: 0;
}
.combat-log-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    color: #8a8fa8;
    border-bottom: 1px solid #1e2030;
}
.combat-log-header .material-symbols-outlined { font-size: 16px; }
.combat-log-entries {
    flex: 1;
    overflow-y: auto;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ====== INITIATIVE CARDS ====== */
.init-card {
    background: #1a1c24;
    border: 1px solid #2a2d35;
    border-radius: 8px;
    padding: 8px 10px;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: border-color 0.2s;
}
.init-card.active {
    border-color: #4fc3f7;
    background: rgba(79, 195, 247, 0.08);
}
.init-card.player-card.active { border-color: #4fc3f7; }
.init-card.enemy-card.active { border-color: #ff6666; }
.init-badge {
    background: #252836;
    color: #ccc;
    font-size: 12px;
    font-weight: 700;
    min-width: 28px;
    text-align: center;
    padding: 2px 4px;
    border-radius: 4px;
}
.init-card.active .init-badge {
    background: #4fc3f7;
    color: #000;
}
.init-card-header {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
}
.init-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}
.init-avatar.player { background: #4fc3f7; color: #000; }
.init-avatar.enemy-av { background: #ff6666; color: #fff; }
.init-info { min-width: 0; }
.init-name {
    font-size: 12px;
    font-weight: 600;
    color: #e0e0e0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.init-subtitle {
    font-size: 10px;
    color: #666;
}
.init-subtitle.active-turn {
    color: #4fc3f7;
    font-weight: 600;
}
.init-hp-bar {
    height: 3px;
    background: #252836;
    border-radius: 2px;
    margin-top: 4px;
}
.init-hp-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s;
}
.init-hp-fill.high { background: #4caf50; }
.init-hp-fill.mid { background: #ff9800; }
.init-hp-fill.low { background: #f44336; }

/* ====== PLAYER STATUS (RIGHT) ====== */
.combat-player-status {
    margin-bottom: 4px;
}
.combat-player-mini-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #aaa;
    margin-bottom: 4px;
}
.combat-player-mini-row span:first-child { min-width: 42px; }
.combat-player-mini-row span:last-child { font-size: 11px; color: #888; min-width: 50px; text-align: right; }
.hp-bar-container.mini {
    flex: 1;
    height: 6px;
    background: #252836;
    border-radius: 3px;
    overflow: hidden;
}

/* ====== ACTION CARDS ====== */
.combat-actions-title {
    font-size: 12px;
    font-weight: 600;
    color: #8a8fa8;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
}
.combat-actions-title .material-symbols-outlined { font-size: 14px; color: #ffab40; }
.combat-section-subtitle {
    font-size: 11px;
    color: #666;
    padding: 2px 0;
}
.combat-section-divider {
    height: 1px;
    background: #252836;
    margin: 6px 0;
}
.combat-action-grid {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.combat-action-card {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid #2a2d35;
    background: #1a1c24;
    color: #ccc;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.15s;
}
.combat-action-card:hover {
    background: #252836;
    border-color: #4fc3f7;
}
.combat-action-card .material-symbols-outlined { font-size: 14px; }
.combat-action-card.attack { border-color: #f44336; color: #f44336; }
.combat-action-card.attack:hover { background: rgba(244, 67, 54, 0.1); }
.combat-action-card.flee { border-color: #ff9800; color: #ff9800; }
.combat-action-card.flee:hover { background: rgba(255, 152, 0, 0.1); }
.combat-action-card.endturn {
    border-color: #4fc3f7;
    color: #4fc3f7;
}
.combat-action-card.endturn:hover {
    background: rgba(79, 195, 247, 0.1);
}
.combat-action-card.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.combat-main-actions {
    flex-direction: row;
    flex-wrap: wrap;
}
.combat-main-actions .combat-action-card {
    flex: 1;
    min-width: 0;
    justify-content: center;
}
.btn-close-combat {
    width: 100%;
    padding: 8px;
    margin-top: 8px;
    border-radius: 6px;
    border: 1px solid #4caf50;
    background: rgba(76, 175, 80, 0.15);
    color: #4caf50;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}
.btn-close-combat:hover {
    background: rgba(76, 175, 80, 0.3);
}

/* Potions */
.combat-potions {
    display: flex;
    gap: 4px;
}
.combat-potion-btn {
    flex: 1;
    display: flex;
    justify-content: space-between;
    padding: 5px 8px;
    border-radius: 6px;
    border: 1px solid #2a2d35;
    background: #1a1c24;
    color: #ccc;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.15s;
}
.combat-potion-btn:hover { background: #252836; }
.combat-potion-btn.health { border-color: #f44336; }
.combat-potion-btn.mana { border-color: #4fc3f7; }
.combat-potion-btn.disabled { opacity: 0.4; cursor: not-allowed; }

/* Responsive */
@media (max-width: 768px) {
    .combat-3col {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto;
    }
    .combat-cell { width: 22px; height: 22px; }
    .combat-token { width: 18px; height: 18px; font-size: 10px; }
}

/* Basic attack button */
.combat-action-card.basic-attack {
    background: linear-gradient(135deg, #b71c1c, #d32f2f) !important;
    border: 1px solid #ff5252 !important;
    color: white !important;
    font-weight: bold;
    grid-column: 1 / -1;
}
.combat-action-card.basic-attack:hover {
    background: linear-gradient(135deg, #d32f2f, #f44336) !important;
    box-shadow: 0 0 12px rgba(255, 82, 82, 0.5);
}

/* ============================================================================
   TARGET SELECTION — Highlight valid targets for attack/ability
   ============================================================================ */

.combat-cell.targetable {
    position: relative;
    cursor: crosshair;
    animation: targetPulse 1.5s ease-in-out infinite;
}

.combat-cell.targetable .combat-token {
    box-shadow: 0 0 12px 4px rgba(255, 215, 0, 0.8), 0 0 24px 8px rgba(255, 215, 0, 0.3) !important;
    border: 2px solid #FFD700 !important;
    transform: scale(1.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

.combat-cell.targetable:hover .combat-token {
    transform: scale(1.25);
    box-shadow: 0 0 16px 6px rgba(255, 215, 0, 1), 0 0 32px 12px rgba(255, 215, 0, 0.5) !important;
}

.combat-cell.targetable::after {
    content: '⊕';
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 0.7em;
    color: #FFD700;
    opacity: 0.8;
    pointer-events: none;
    text-shadow: 0 0 4px rgba(255, 215, 0, 0.6);
}

@keyframes targetPulse {
    0%, 100% { box-shadow: inset 0 0 8px rgba(255, 215, 0, 0.3); }
    50% { box-shadow: inset 0 0 18px rgba(255, 215, 0, 0.7); }
}

/* Enemy targets — red tint */
.combat-cell.targetable.enemy-cell .combat-token {
    box-shadow: 0 0 12px 4px rgba(255, 80, 80, 0.8), 0 0 24px 8px rgba(255, 80, 80, 0.3) !important;
    border: 2px solid #ff5050 !important;
}

.combat-cell.targetable.enemy-cell:hover .combat-token {
    box-shadow: 0 0 16px 6px rgba(255, 80, 80, 1), 0 0 32px 12px rgba(255, 80, 80, 0.5) !important;
}

.combat-cell.targetable.enemy-cell::after {
    content: '⚔';
    color: #ff5050;
    text-shadow: 0 0 4px rgba(255, 80, 80, 0.6);
}

/* Player/allies targets — green tint for heals/buffs */
.combat-cell.targetable.player-cell .combat-token {
    box-shadow: 0 0 12px 4px rgba(80, 255, 80, 0.8), 0 0 24px 8px rgba(80, 255, 80, 0.3) !important;
    border: 2px solid #50ff50 !important;
}

.combat-cell.targetable.player-cell:hover .combat-token {
    box-shadow: 0 0 16px 6px rgba(80, 255, 80, 1), 0 0 32px 12px rgba(80, 255, 80, 0.5) !important;
}

.combat-cell.targetable.player-cell::after {
    content: '✚';
    color: #50ff50;
    text-shadow: 0 0 4px rgba(80, 255, 80, 0.6);
}

/* ===== COMBAT ACTION ECONOMY ===== */
.combat-economy {
    padding: 8px 12px;
    background: var(--surface-container-low);
    border-radius: var(--radius-md);
    margin: 0 8px;
}
.combat-econ-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--on-surface-variant);
    opacity: 0.7;
    margin-bottom: 6px;
}
.combat-econ-row {
    display: flex;
    gap: 4px;
}
.combat-econ-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 4px;
    border-radius: var(--radius-sm);
    background: var(--surface-container);
    border: 1px solid var(--outline-variant);
    transition: all 0.2s;
}
.combat-econ-item .material-symbols-outlined {
    font-size: 18px;
    color: var(--on-surface);
}
.econ-label {
    font-size: 0.6rem;
    color: var(--on-surface-variant);
    text-align: center;
    line-height: 1.1;
}
.econ-status {
    font-size: 0.75rem;
    font-weight: 700;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.econ-ready {
    background: #1b5e20;
    color: #66bb6a;
}
.econ-used {
    background: #424242;
    color: #757575;
}

/* ===== COMBAT MAP TOKENS ===== */
.combat-token {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 1.2rem;
    position: relative;
    overflow: hidden;
}
.combat-token img {
    width: 80%;
    height: 80%;
    object-fit: contain;
    filter: drop-shadow(0 2px 3px rgba(0,0,0,0.5));
}
.combat-token .cond-icon {
    position: absolute;
    top: -4px;
    right: -4px;
    font-size: 12px;
    z-index: 2;
}

/* ===== COMBAT MAIN ACTIONS (End Turn + Flee) ===== */
.combat-main-actions {
    display: flex;
    gap: 6px;
    padding: 0 8px 8px;
}
.combat-main-actions .combat-action-card {
    flex: 1;
    font-size: 0.75rem;
    padding: 8px 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}
.combat-action-card.flee {
    background: var(--surface-container-high);
    color: var(--on-surface);
}
.combat-action-card.flee:hover {
    background: #5a3a2a;
}
.combat-action-card.flee .material-symbols-outlined {
    font-size: 20px;
}
.combat-action-card.endturn {
    background: #1a3a5a;
}
.combat-action-card.endturn:hover {
    background: #2a4a6a;
}

/* Death save button */
.combat-action-card.death-save {
    background: linear-gradient(135deg, #8B4513, #D2691E);
    border-color: #FFD700;
    animation: deathPulse 1s ease-in-out infinite;
}
@keyframes deathPulse {
    0%, 100% { box-shadow: 0 0 8px rgba(255,215,0,0.3); }
    50% { box-shadow: 0 0 20px rgba(255,215,0,0.7); }
}