/* ============================================
   WEAPON BALL AUTO-BATTLER — Earclacks Style v3
   Combat Overhaul
   ============================================ */

/* ── Overlay Container ── */
#ball-arena-ui {
    position: absolute;
    inset: 0;
    z-index: 100;
    font-family: 'Segoe UI', 'Inter', Arial, sans-serif;
    overflow: hidden;
}

/* ── MENU SCREEN ── */
#ball-arena-menu {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    background: radial-gradient(ellipse at center, #1a1a2e 0%, #0a0a15 100%);
    padding: 20px;
    overflow-y: auto;
    padding-top: 40px;
}

.ba-title {
    font-size: 3rem;
    font-weight: 900;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 4px;
    text-shadow: 0 0 20px rgba(231, 76, 60, 0.6), 0 0 60px rgba(231, 76, 60, 0.3);
    margin-bottom: 8px;
}

.ba-subtitle {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 20px;
    letter-spacing: 2px;
}

/* ── Picking Phase ── */
.ba-pick-label {
    font-size: 1.4rem;
    font-weight: 700;
    color: #3498db;
    margin-bottom: 16px;
    text-shadow: 0 0 10px rgba(52, 152, 219, 0.4);
    transition: all 0.3s ease;
}

.ba-pick-label.p2 {
    color: #e74c3c;
    text-shadow: 0 0 10px rgba(231, 76, 60, 0.4);
}

/* ── Weapon Grid ── */
#ba-weapon-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    max-width: 700px;
    width: 100%;
    padding: 10px;
}

.ba-weapon-card {
    position: relative;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 24px 16px 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    overflow: hidden;
}

.ba-weapon-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.08), transparent);
    transition: left 0.5s ease;
    pointer-events: none;
}

.ba-weapon-card:hover::before {
    left: 100%;
}

.ba-weapon-card:hover {
    transform: translateY(-4px) scale(1.03);
    border-color: rgba(255, 255, 255, 0.3);
}

.ba-weapon-card * {
    pointer-events: none;
}

.ba-weapon-card.selected {
    border-color: #3498db;
    box-shadow: 0 0 20px rgba(52, 152, 219, 0.5), inset 0 0 20px rgba(52, 152, 219, 0.1);
    animation: ba-card-selected 0.4s ease;
}

.ba-weapon-card.selected.p2 {
    border-color: #e74c3c;
    box-shadow: 0 0 20px rgba(231, 76, 60, 0.5), inset 0 0 20px rgba(231, 76, 60, 0.1);
}

@keyframes ba-card-selected {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.08);
    }

    100% {
        transform: scale(1);
    }
}

.ba-weapon-preview {
    width: 80px;
    height: 80px;
    margin: 0 auto 8px;
    pointer-events: none;
}

.ba-weapon-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 4px;
    pointer-events: none;
}

.ba-weapon-desc {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    line-height: 1.3;
    pointer-events: none;
}

.ba-weapon-stats {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 8px;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.6);
    pointer-events: none;
}

.ba-weapon-stats span {
    background: rgba(255, 255, 255, 0.06);
    padding: 2px 8px;
    border-radius: 6px;
}

/* ── Settings Panel ── */
#ba-settings-panel {
    max-width: 700px;
    width: 100%;
    margin-top: 16px;
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    display: flex;
    align-items: center;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

.ba-setting-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
}

.ba-setting-toggle {
    display: flex;
    gap: 6px;
}

.ba-setting-btn {
    padding: 6px 16px;
    font-size: 0.8rem;
    font-weight: 700;
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    transition: all 0.2s ease;
}

.ba-setting-btn.active {
    border-color: #f39c12;
    background: rgba(243, 156, 18, 0.15);
    color: #f1c40f;
    box-shadow: 0 0 10px rgba(243, 156, 18, 0.25);
}

.ba-setting-btn:hover:not(.active) {
    border-color: rgba(255, 255, 255, 0.3);
    color: #fff;
}

/* ── Buttons ── */
.ba-btn {
    padding: 14px 40px;
    font-size: 1.3rem;
    font-weight: 700;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.ba-btn-fight {
    background: linear-gradient(135deg, #2ecc71, #27ae60);
    color: #fff;
    box-shadow: 0 4px 15px rgba(46, 204, 113, 0.4);
}

.ba-btn-fight:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(46, 204, 113, 0.6);
}

.ba-btn-fight:disabled {
    background: #333;
    color: #666;
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

.ba-btn-exit {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: #fff;
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.3);
}

.ba-btn-exit:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(231, 76, 60, 0.5);
}

.ba-btn-group {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

/* ── BATTLE HUD ── */
#ba-hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: none;
    z-index: 200;
}

.ba-player-hud {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 300px;
}

.ba-player-hud.right {
    align-items: flex-end;
    text-align: right;
}

.ba-player-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    gap: 8px;
}

.ba-level-badge {
    font-size: 0.65rem;
    background: rgba(243, 156, 18, 0.8);
    color: #fff;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 700;
}

.ba-hp-bar-bg {
    width: 100%;
    height: 12px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    overflow: hidden;
}

.ba-hp-bar-fill {
    height: 100%;
    border-radius: 6px;
    transition: width 0.15s ease;
    background: linear-gradient(90deg, #2ecc71, #27ae60);
    box-shadow: 0 0 8px rgba(46, 204, 113, 0.5);
}

.ba-hp-bar-fill.low {
    background: linear-gradient(90deg, #e74c3c, #c0392b);
    box-shadow: 0 0 8px rgba(231, 76, 60, 0.5);
}

.ba-hp-text {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.6);
    font-weight: 600;
}

/* ── SKILL PANEL ── */
#ba-skill-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 8px 16px 12px;
    pointer-events: none;
    z-index: 200;
}

.ba-skill-row {
    display: flex;
    gap: 4px;
    align-items: flex-end;
}

.ba-skill-row.right {
    flex-direction: row-reverse;
}

.ba-skill-slot {
    width: 50px;
    height: 56px;
    background: rgba(0, 0, 0, 0.65);
    border: 2px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.ba-skill-slot.locked {
    opacity: 0.35;
    border-color: rgba(255, 255, 255, 0.05);
}

.ba-skill-slot.locked::after {
    content: '🔒';
    position: absolute;
    font-size: 14px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.ba-skill-slot.unlocked {
    border-color: rgba(243, 156, 18, 0.5);
    background: rgba(243, 156, 18, 0.1);
}

.ba-skill-slot.ready {
    border-color: rgba(46, 204, 113, 0.7);
    background: rgba(46, 204, 113, 0.12);
    box-shadow: 0 0 8px rgba(46, 204, 113, 0.3);
}

.ba-skill-slot.on-cooldown {
    border-color: rgba(231, 76, 60, 0.4);
}

.ba-skill-icon {
    width: 52px;
    height: 58px;
    background: rgba(0, 0, 0, 0.65);
    border: 2px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    font-size: 16px;
    line-height: 1;
}

.ba-skill-icon.locked {
    opacity: 0.35;
    border-color: rgba(255, 255, 255, 0.05);
}

.ba-skill-icon.ready {
    border-color: rgba(46, 204, 113, 0.7);
    background: rgba(46, 204, 113, 0.12);
    box-shadow: 0 0 8px rgba(46, 204, 113, 0.3);
}

.ba-skill-icon.on-cooldown {
    border-color: rgba(231, 76, 60, 0.4);
}

.ba-skill-emoji {
    font-size: 18px;
}

.ba-skill-name {
    font-size: 6px;
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
    max-width: 48px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: 2px;
}

.ba-skill-cd {
    font-size: 8px;
    color: #e74c3c;
    font-weight: 700;
}

.ba-skill-name-label {
    font-size: 6px;
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
    line-height: 1.1;
    margin-top: 2px;
    max-width: 46px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ba-skill-cd-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 0%;
    background: rgba(0, 0, 0, 0.6);
    transition: height 0.2s ease;
}

.ba-skill-cd-text {
    position: absolute;
    top: 2px;
    right: 3px;
    font-size: 8px;
    color: #e74c3c;
    font-weight: 700;
}

.ba-skill-lv-label {
    position: absolute;
    bottom: 1px;
    left: 3px;
    font-size: 7px;
    color: rgba(255, 255, 255, 0.4);
    font-weight: 600;
}

/* ── Countdown ── */
#ba-countdown {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8rem;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 0 40px rgba(231, 76, 60, 0.8), 0 0 80px rgba(231, 76, 60, 0.4);
    z-index: 300;
    pointer-events: none;
    background: rgba(0, 0, 0, 0.6);
    opacity: 0;
    transition: opacity 0.3s ease;
}

#ba-countdown.visible {
    opacity: 1;
}

/* ── CLASH OVERLAY ── */
#ba-clash-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.85);
    z-index: 400;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

#ba-clash-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.ba-clash-title {
    font-size: 3.5rem;
    font-weight: 900;
    color: #f1c40f;
    text-shadow: 0 0 40px rgba(241, 196, 15, 0.8);
    letter-spacing: 6px;
    animation: ba-clash-pulse 0.8s ease infinite;
    margin-bottom: 30px;
}

@keyframes ba-clash-pulse {

    0%,
    100% {
        transform: scale(1);
        text-shadow: 0 0 40px rgba(241, 196, 15, 0.8);
    }

    50% {
        transform: scale(1.1);
        text-shadow: 0 0 80px rgba(241, 196, 15, 1);
    }
}

.ba-clash-coins {
    display: flex;
    gap: 80px;
    align-items: center;
    margin-bottom: 20px;
}

.ba-clash-coin {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    font-weight: 900;
    color: #fff;
    border: 4px solid rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
}

.ba-clash-coin.p1 {
    background: radial-gradient(circle, #3498db, #2471a3);
    box-shadow: 0 0 30px rgba(52, 152, 219, 0.6);
}

.ba-clash-coin.p2 {
    background: radial-gradient(circle, #e74c3c, #c0392b);
    box-shadow: 0 0 30px rgba(231, 76, 60, 0.6);
}

.ba-clash-coin.winner {
    transform: scale(1.3);
    border-color: #f1c40f;
    box-shadow: 0 0 50px rgba(241, 196, 15, 0.8);
}

.ba-clash-coin.loser {
    transform: scale(0.8);
    opacity: 0.5;
    filter: grayscale(0.5);
}

.ba-clash-vs {
    font-size: 2rem;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.5);
}

.ba-clash-result {
    font-size: 1.5rem;
    font-weight: 700;
    color: #2ecc71;
    text-shadow: 0 0 15px rgba(46, 204, 113, 0.5);
    margin-top: 10px;
    min-height: 2em;
}

/* ── Result Screen ── */
#ba-result {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.85);
    z-index: 300;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

#ba-result.visible {
    opacity: 1;
    pointer-events: auto;
}

.ba-result-title {
    font-size: 4rem;
    font-weight: 900;
    color: #f1c40f;
    text-shadow: 0 0 30px rgba(241, 196, 15, 0.6);
    margin-bottom: 10px;
    animation: ba-result-pulse 1.5s ease infinite;
}

@keyframes ba-result-pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

.ba-result-sub {
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 30px;
}

/* ── Battle Log ── */
#ba-battle-log {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    pointer-events: none;
    z-index: 150;
}

.ba-log-entry {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.7);
    background: rgba(0, 0, 0, 0.5);
    padding: 3px 12px;
    border-radius: 8px;
    animation: ba-log-fade 3s ease forwards;
}

@keyframes ba-log-fade {
    0% {
        opacity: 1;
    }

    80% {
        opacity: 1;
    }

    100% {
        opacity: 0;
        transform: translateY(-20px);
    }
}

/* ── Skill Toast ── */
.ba-skill-toast {
    position: absolute;
    font-size: 1.6rem;
    font-weight: 900;
    pointer-events: none;
    z-index: 250;
    animation: ba-skill-toast-anim 1.2s ease forwards;
    white-space: nowrap;
}

.ba-skill-toast.p1 {
    left: 10%;
    color: #3498db;
    text-shadow: 0 0 15px rgba(52, 152, 219, 0.6), 2px 2px 0 rgba(0, 0, 0, 0.6);
}

.ba-skill-toast.p2 {
    right: 10%;
    color: #e74c3c;
    text-shadow: 0 0 15px rgba(231, 76, 60, 0.6), 2px 2px 0 rgba(0, 0, 0, 0.6);
}

@keyframes ba-skill-toast-anim {
    0% {
        opacity: 0;
        transform: translateY(0) scale(0.5);
    }

    20% {
        opacity: 1;
        transform: translateY(-20px) scale(1.1);
    }

    70% {
        opacity: 1;
    }

    100% {
        opacity: 0;
        transform: translateY(-60px) scale(0.8);
    }
}

/* ── Level Up Flash ── */
.ba-levelup-flash {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 190;
    background: radial-gradient(circle, rgba(243, 156, 18, 0.3) 0%, transparent 70%);
    animation: ba-luf 0.6s ease forwards;
}

@keyframes ba-luf {
    0% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

/* ── Responsive ── */
@media (max-width: 600px) {
    #ba-weapon-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .ba-title {
        font-size: 2rem;
    }

    .ba-weapon-preview {
        width: 60px;
        height: 60px;
    }

    .ba-weapon-card {
        padding: 16px 10px 12px;
    }

    .ba-player-hud {
        min-width: 140px;
    }

    .ba-skill-slot {
        width: 38px;
        height: 44px;
    }

    .ba-skill-icon {
        font-size: 13px;
    }

    .ba-clash-coin {
        width: 70px;
        height: 70px;
        font-size: 2rem;
    }
}