/* ============================================================
   Animação de Evolução de Level (pós-batalha) — v7
   - Animação única: 16 feixos dourados + giro leve + cintilação
     em X + box com borda arco-íris.
   - Tela de conclusão com informativo "MESTRE EVOLUIU".
   ============================================================ */

/* Overlay base */
.evol-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 50;
    overflow: visible;
}
.evol-overlay.is-fade { animation: evol-overlay-fade 0.6s ease-out forwards; }

/* Flash branco final */
.evol-flash {
    position: absolute;
    inset: -150%;
    background: radial-gradient(circle at center,
        rgba(255,255,255,0.95),
        rgba(255,255,255,0.55) 35%,
        rgba(255,255,255,0) 70%);
    opacity: 0;
    pointer-events: none;
    mix-blend-mode: screen;
}
.evol-overlay.is-flash .evol-flash { animation: evol-flash-pop 0.5s ease-out forwards; }

/* FEIXO DE LUZ */
.evol-beam {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 200%;
    height: 230%;
    transform: translate(-50%, -50%) rotate(var(--ang, 0deg)) scale(0);
    background: radial-gradient(ellipse 3% 50% at 50% 0%,
        var(--bc2, #fff) 0%,
        var(--bc, #fff) 18%,
        rgba(255,255,255,0.85) 32%,
        rgba(255,255,255,0) 72%);
    opacity: 0;
    mix-blend-mode: screen;
    filter: blur(0.6px);
    pointer-events: none;
}
.evol-overlay.is-climax .evol-beam {
    animation: evol-beam-flash 0.95s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.evol-beams-radial {
    position: absolute;
    inset: 0;
    transform-origin: center;
}
.evol-overlay.is-climax .evol-beams-radial {
    animation: evol-beams-spin 3s linear forwards;
}

/* Cintilação em X */
.evol-twinkle {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 260%;
    height: 260%;
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
    pointer-events: none;
    mix-blend-mode: screen;
}
.evol-twinkle::before,
.evol-twinkle::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse 50% 2% at 50% 50%,
        rgba(255,255,255,1) 0%,
        rgba(255,255,255,0.9) 10%,
        rgba(255,255,255,0) 50%);
}
.evol-twinkle::after { transform: rotate(90deg); }
.evol-overlay.is-climax .evol-twinkle { animation: evol-twinkle-mid 1.4s ease-out forwards; }
.evol-overlay.is-reveal .evol-twinkle { animation: evol-twinkle-pop 0.8s ease-out forwards; }

/* BOX de info (XP + Level) — sempre com borda arco-íris */
.evol-box {
    position: absolute;
    z-index: 51;
    min-width: 180px;
    padding: 10px 14px;
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(20, 20, 24, 0.96), rgba(10, 10, 12, 0.96));
    border: 2px solid transparent;
    border-image: conic-gradient(#ff3a3a, #ffe04a, #4dba60, #4dafff, #d472d4, #ff3a3a) 1;
    border-image-slice: 1;
    box-shadow: 0 6px 18px rgba(0,0,0,0.55),
                0 0 18px rgba(255,255,255,0.3),
                0 0 36px rgba(180,180,255,0.4);
    color: #fff;
    text-align: center;
    font-family: inherit;
    pointer-events: none;
    opacity: 0;
    transform: translateY(20px);
    will-change: transform, opacity;
}
.evol-box.is-visible { animation: evol-box-rise 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) forwards; }
.evol-box.is-fade    { animation: evol-box-fade-out 0.6s ease-in forwards; }
.evol-box-title {
    font-size: 12px; font-weight: 800; letter-spacing: 1.6px;
    color: #ffd97a; text-shadow: 0 0 8px rgba(255,217,122,0.7);
    margin-bottom: 4px;
}
.evol-box-name {
    font-size: 14px; font-weight: 700; color: #fff;
    margin-bottom: 6px; text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}
.evol-box-xp {
    font-size: 13px; font-weight: 700; color: #7df0a8;
    margin-bottom: 2px; text-shadow: 0 0 6px rgba(125,240,168,0.6);
}
.evol-box-level { font-size: 13px; font-weight: 600; color: #f4e8c8; }
.evol-box-lvl-old { color: #b8a878; }
.evol-box-lvl-new {
    color: #ffd97a; font-weight: 800; font-size: 15px;
    text-shadow: 0 0 10px rgba(255,217,122,0.8);
}

/* Sprite glow (único, dourado) */
.evol-sprite-pulse {
    animation: evol-sprite-glow 2.8s cubic-bezier(0.42, 0, 0.58, 1);
}

/* ============================================================
   KEYFRAMES — animação
   ============================================================ */
@keyframes evol-overlay-fade { 0% { opacity: 1; } 100% { opacity: 0; } }
@keyframes evol-flash-pop    { 0% { opacity: 0; } 40% { opacity: 1; } 100% { opacity: 0; } }

@keyframes evol-beam-flash {
    0%   { transform: translate(-50%, -50%) rotate(var(--ang, 0deg)) scale(0.3); opacity: 0; }
    25%  { transform: translate(-50%, -50%) rotate(var(--ang, 0deg)) scale(1);   opacity: 1; }
    70%  { transform: translate(-50%, -50%) rotate(var(--ang, 0deg)) scale(1.05); opacity: 0.9; }
    100% { transform: translate(-50%, -50%) rotate(var(--ang, 0deg)) scale(1.3); opacity: 0; }
}
@keyframes evol-beams-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(25deg); }
}
@keyframes evol-twinkle-mid {
    0%   { transform: translate(-50%, -50%) scale(0)   rotate(0deg);  opacity: 0; }
    50%  { transform: translate(-50%, -50%) scale(1)   rotate(15deg); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1.2) rotate(30deg); opacity: 0; }
}
@keyframes evol-twinkle-pop {
    0%   { transform: translate(-50%, -50%) scale(0)   rotate(0deg);  opacity: 0; }
    35%  { transform: translate(-50%, -50%) scale(1)   rotate(20deg); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1.5) rotate(45deg); opacity: 0; }
}
@keyframes evol-box-rise {
    0%   { opacity: 0; transform: translateY(20px) scale(0.85); }
    100% { opacity: 1; transform: translateY(0)    scale(1); }
}
@keyframes evol-box-fade-out {
    0%   { opacity: 1; transform: translateY(0)    scale(1); }
    100% { opacity: 0; transform: translateY(-12px) scale(0.95); }
}
@keyframes evol-sprite-glow {
    0%   { transform: translateY(0)    scale(1);    filter: brightness(1) drop-shadow(0 0 0 rgba(255,217,122,0)); }
    55%  { transform: translateY(-6px) scale(1.03); filter: brightness(1.5)  drop-shadow(0 0 26px rgba(255,217,122,0.95)); }
    100% { transform: translateY(0)    scale(1);    filter: brightness(1) drop-shadow(0 0 0 rgba(255,217,122,0)); }
}

/* ============================================================
   TELA DE CONCLUSÃO COM INFORMATIVO DE EVOLUÇÃO DO MESTRE
   ============================================================ */
.evol-end-backdrop {
    position: fixed;
    inset: 0;
    z-index: 999999;
    background: rgba(0, 0, 0, 0.75);
    -webkit-backdrop-filter: blur(6px);
            backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.25s ease;
    padding: 16px;
}
.evol-end-backdrop.is-closing { opacity: 0; }

.evol-end-card {
    position: relative;
    width: 100%;
    max-width: 500px;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    padding: 32px 28px 26px;
    border-radius: 22px;
    background: linear-gradient(180deg, rgba(28, 28, 36, 0.98), rgba(16, 16, 22, 0.98));
    border: 3px solid transparent;
    border-image: conic-gradient(#ff3a3a, #ff9933, #ffe04a, #4dba60, #4dafff, #7c5fb0, #d472d4, #ff3a3a) 1;
    border-image-slice: 1;
    box-shadow:
        0 16px 50px rgba(0, 0, 0, 0.7),
        0 0 40px rgba(255, 217, 122, 0.35),
        0 0 80px rgba(180, 180, 255, 0.22);
    opacity: 0;
    transform: translateY(30px) scale(0.9);
    animation: evol-end-card-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.12s forwards;
    overflow: hidden;
}

.evol-end-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    background:
        radial-gradient(circle at 50% 0%, rgba(255, 217, 122, 0.22), transparent 55%),
        radial-gradient(circle at 50% 100%, rgba(180, 180, 255, 0.12), transparent 55%);
}

.evol-end-trophy {
    text-align: center;
    font-size: 46px;
    margin-bottom: 4px;
    filter: drop-shadow(0 0 20px rgba(255, 217, 122, 0.85));
    opacity: 0;
    transform: scale(0.5);
    animation: evol-end-trophy-pop 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) 0.35s forwards;
}

.evol-end-title {
    text-align: center;
    font-size: 22px;
    font-weight: 800;
    letter-spacing: 2.5px;
    color: #fff;
    text-shadow: 0 0 14px rgba(255, 217, 122, 0.65);
    margin-bottom: 4px;
    opacity: 0;
    animation: evol-fade-up 0.4s ease-out 0.5s forwards;
    position: relative;
}

.evol-end-subtitle {
    text-align: center;
    font-size: 12px;
    color: #c8b890;
    letter-spacing: 1.5px;
    margin-bottom: 24px;
    opacity: 0;
    animation: evol-fade-up 0.4s ease-out 0.6s forwards;
    position: relative;
}

.evol-mestre-info {
    position: relative;
    padding: 18px 18px 16px;
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(48, 38, 18, 0.55), rgba(30, 24, 12, 0.55));
    border: 1px solid rgba(255, 217, 122, 0.45);
    box-shadow: inset 0 0 22px rgba(255, 217, 122, 0.08);
    margin-bottom: 22px;
    overflow: hidden;
    opacity: 0;
    transform: translateY(10px);
    animation: evol-fade-up 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.7s forwards;
    text-align: center;
}

.evol-mestre-info::before {
    content: '';
    position: absolute;
    top: 0; bottom: 0;
    left: -50%;
    width: 50%;
    background: linear-gradient(90deg,
        rgba(255, 217, 122, 0) 0%,
        rgba(255, 217, 122, 0.2) 50%,
        rgba(255, 217, 122, 0) 100%);
    animation: evol-mestre-shine 3.2s ease-in-out 1.1s infinite;
    pointer-events: none;
}

.evol-mestre-badge {
    display: inline-block;
    padding: 4px 14px;
    border-radius: 20px;
    background: linear-gradient(90deg, #ffd97a, #fff4c8 50%, #ffd97a);
    background-size: 200% 100%;
    color: #4a3000;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1.8px;
    margin-bottom: 14px;
    box-shadow: 0 0 14px rgba(255, 217, 122, 0.65);
    animation: evol-badge-shimmer 2.6s ease-in-out infinite;
    position: relative;
}

.evol-mestre-name {
    font-size: 17px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 14px;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
    position: relative;
}

.evol-mestre-levels {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 14px;
    position: relative;
}

.evol-mestre-lvl-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 72px;
    padding: 8px 14px;
    border-radius: 12px;
}

.evol-mestre-lvl-old {
    background: rgba(60, 56, 40, 0.55);
    color: #b8a878;
    border: 1px solid rgba(184, 168, 120, 0.35);
}

.evol-mestre-lvl-new {
    background: linear-gradient(180deg, rgba(255, 217, 122, 0.32), rgba(255, 217, 122, 0.12));
    color: #ffd97a;
    border: 1.5px solid rgba(255, 217, 122, 0.75);
    text-shadow: 0 0 10px rgba(255, 217, 122, 0.85);
    box-shadow: 0 0 20px rgba(255, 217, 122, 0.35);
    animation: evol-lvl-new-pulse 1.9s ease-in-out 1s infinite;
}

.evol-mestre-lvl-label {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1.2px;
    opacity: 0.85;
    margin-bottom: 3px;
    text-transform: uppercase;
}

.evol-mestre-lvl-num {
    font-size: 26px;
    font-weight: 900;
    line-height: 1;
}

.evol-mestre-arrow {
    color: #ffd97a;
    font-size: 26px;
    font-weight: 900;
    text-shadow: 0 0 12px rgba(255, 217, 122, 0.85);
    animation: evol-arrow-slide 1.4s ease-in-out infinite;
}

.evol-mestre-stats {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    position: relative;
}

.evol-mestre-chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
}

.evol-mestre-chip.is-xp {
    background: rgba(125, 240, 168, 0.18);
    border: 1px solid rgba(125, 240, 168, 0.5);
    color: #7df0a8;
    text-shadow: 0 0 6px rgba(125, 240, 168, 0.55);
}

.evol-mestre-chip.is-levels {
    background: rgba(255, 217, 122, 0.18);
    border: 1px solid rgba(255, 217, 122, 0.5);
    color: #ffd97a;
    text-shadow: 0 0 6px rgba(255, 217, 122, 0.55);
}

/* ===== BOX FLUTUANTE DE EVOLU\u{c7}\u{c3}O DO MONSTRO (na tela de resultado) =====
   Variante da .evol-box (arena) com position:fixed, ancorada ao "+N" clicado.
   Mostra Nv antes\u{2192}depois + atributos ganhos. Some sozinha em ~5s. */
.evol-box.evol-box-floating {
    position: fixed;
    z-index: 16000; /* acima do .mestrar-bn-end-bd (15000) */
    box-sizing: border-box;
    min-width: 200px;
    max-width: 280px;
    width: 240px;
    padding: 12px 14px;
    pointer-events: none;
}
.evol-box-monster .evol-box-title {
    color: #d8baff;
    text-shadow: 0 0 8px rgba(179, 136, 224, 0.7);
}
.evol-box-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 8px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 217, 122, 0.2);
}
.evol-box-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2px 6px;
    border-radius: 5px;
    background: rgba(0, 0, 0, 0.35);
    font-size: 11px;
}
.evol-box-stat-lbl {
    color: #e4dccc;
    opacity: 0.88;
    font-weight: 600;
}
.evol-box-stat-val {
    font-family: 'Cinzel', serif;
    font-weight: 800;
}
.evol-box-stat-val.is-up {
    color: #7df0a8;
    text-shadow: 0 0 5px rgba(125, 240, 168, 0.55);
}
.evol-box-stat-val.is-down { color: #ff9090; }
.evol-box-stats-empty {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 217, 122, 0.2);
    text-align: center;
    color: rgba(228, 220, 204, 0.55);
    font-size: 11px;
    font-style: italic;
}

/* ===== VARIANTE INLINE da caixa MESTRE EVOLUIU =====
   Para uso DENTRO da tela de resultado existente (battle-result-summary
   no mapa, mestrar-end-victory na narrada). Não tem entrada com fade-up
   stagger nem expects um modal wrapper. */
.evol-mestre-info.evol-mestre-info-inline {
    opacity: 1;
    transform: none;
    animation: none;
    margin: 8px 0 14px;
    max-width: 100%;
    box-sizing: border-box;
}

.evol-mestre-chip.is-points {
    background: rgba(180, 180, 255, 0.16);
    border: 1px solid rgba(180, 180, 255, 0.45);
    color: #c8caff;
    text-shadow: 0 0 6px rgba(180, 180, 255, 0.5);
}

/* ===== RESUMO COMPLETO DA BATALHA (dentro do card) ===== */
.evol-res-section {
    position: relative;
    padding: 16px 18px;
    border-radius: 12px;
    background: linear-gradient(180deg, rgba(30, 30, 38, 0.7), rgba(18, 18, 24, 0.7));
    border: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 20px;
    opacity: 0;
    transform: translateY(8px);
    animation: evol-fade-up 0.45s ease-out 0.85s forwards;
}

.evol-res-section-title {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: #ffd97a;
    opacity: 0.85;
    margin-bottom: 10px;
    text-align: center;
}

.evol-res-line {
    font-size: 13px;
    line-height: 1.55;
    color: #e4dccc;
    padding: 2px 0;
}

.evol-res-line strong {
    color: #fff4c8;
    font-weight: 700;
}

.evol-res-line-lvlup {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 8px;
    border-radius: 8px;
    background: rgba(125, 240, 168, 0.2);
    border: 1px solid rgba(125, 240, 168, 0.45);
    color: #7df0a8;
    font-size: 11px;
    font-weight: 800;
    text-shadow: 0 0 5px rgba(125, 240, 168, 0.5);
}

.evol-res-divider {
    height: 1px;
    background: linear-gradient(90deg,
        transparent, rgba(255, 217, 122, 0.35), transparent);
    margin: 8px 0;
}

.evol-res-drop {
    display: inline-block;
    margin: 2px 4px 2px 0;
    padding: 2px 10px;
    border-radius: 10px;
    background: rgba(255, 217, 122, 0.14);
    border: 1px solid rgba(255, 217, 122, 0.35);
    color: #ffe8a8;
    font-size: 12px;
    font-weight: 600;
}

.evol-end-close {
    display: block;
    margin: 0 auto;
    padding: 12px 34px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(180deg, #ffd97a, #f5b830);
    color: #2a1a04;
    font-weight: 800;
    font-size: 13px;
    letter-spacing: 1.4px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(255, 217, 122, 0.5);
    transition: transform 0.1s, box-shadow 0.15s;
    opacity: 0;
    animation: evol-fade-up 0.4s ease-out 1.05s forwards;
    position: relative;
}

.evol-end-close:hover {
    transform: translateY(-2px);
    box-shadow: 0 7px 22px rgba(255, 217, 122, 0.7);
}
.evol-end-close:active { transform: translateY(0); }

.evol-end-backdrop.is-closing { animation: evol-end-bd-out 0.25s ease-in forwards; }

@keyframes evol-end-bd-in    { to { opacity: 1; } }
@keyframes evol-end-bd-out   { to { opacity: 0; } }
@keyframes evol-end-card-in  { to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes evol-end-trophy-pop { to { opacity: 1; transform: scale(1); } }
@keyframes evol-fade-up {
    0%   { opacity: 0; transform: translateY(8px); }
    100% { opacity: 1; transform: translateY(0); }
}
@keyframes evol-mestre-shine {
    0%   { left: -50%; }
    100% { left: 100%; }
}
@keyframes evol-badge-shimmer {
    0%, 100% { background-position: 0% 50%; }
    50%      { background-position: 100% 50%; }
}
@keyframes evol-lvl-new-pulse {
    0%, 100% { box-shadow: 0 0 20px rgba(255, 217, 122, 0.35); }
    50%      { box-shadow: 0 0 30px rgba(255, 217, 122, 0.75); }
}
@keyframes evol-arrow-slide {
    0%, 100% { transform: translateX(0); }
    50%      { transform: translateX(6px); }
}
