/* ==========================================
   TELA DE CARREGAMENTO DO COMBATE
========================================== */
.loading-container {
    height: 380px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle, #0f172a 0%, #020617 100%);
    border-radius: 16px;
    border: 1px solid #1e293b;
    box-shadow: inset 0 0 30px rgba(0,0,0,0.8), 0 10px 20px rgba(0,0,0,0.5);
    margin-top: 10px;
}

.loader-wrapper {
    position: relative;
    width: 75px;
    height: 75px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 25px;
}

.loading-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 4px solid transparent;
    border-top-color: #ef4444; 
    border-bottom-color: #3b82f6; 
    animation: spinLoader 1.2s linear infinite;
    box-sizing: border-box;
}

.loading-ring:before {
    content: '';
    position: absolute;
    top: 5px; left: 5px; right: 5px; bottom: 5px;
    border-radius: 50%;
    border: 4px solid transparent;
    border-left-color: #f1c40f; 
    animation: spinLoader 0.8s linear infinite reverse;
    box-sizing: border-box;
}

.loading-icon { font-size: 2.2em; z-index: 5; line-height: 1; margin-top: 2px; }
.loading-title { color: #f8fafc; font-size: 1.3em; font-weight: 800; letter-spacing: 1.5px; text-transform: uppercase; margin: 0; animation: pulseText 2s ease-in-out infinite; text-shadow: 0 0 10px rgba(255,255,255,0.2); }
.loading-subtitle { color: #64748b; font-size: 0.9em; margin-top: 8px; font-weight: 600; }

@keyframes spinLoader { 100% { transform: rotate(360deg); } }
@keyframes pulseText { 0%, 100% { opacity: 0.7; } 50% { opacity: 1; text-shadow: 0 0 15px rgba(255,255,255,0.5); } }

/* ==========================================
   ANIMAÇÕES DE MAGIA E ATAQUE
========================================== */
@keyframes animCorte {
    0% { width: 0px; opacity: 1; transform: translate(-50%, -50%) rotate(45deg); }
    50% { width: 120px; opacity: 1; transform: translate(-50%, -50%) rotate(45deg); }
    100% { width: 160px; opacity: 0; transform: translate(-50%, -50%) rotate(45deg); }
}
.slash-effect { position: absolute; height: 4px; background: #fff; border-radius: 50%; z-index: 30; pointer-events: none; animation: animCorte 0.3s ease-out forwards; }

@keyframes animImpacto {
    0% { width: 10px; height: 10px; opacity: 1; transform: translate(-50%, -50%); }
    100% { width: 60px; height: 60px; opacity: 0; transform: translate(-50%, -50%); border-radius: 50%; }
}
.impact-effect { position: absolute; background: transparent; border: 4px solid #fff; z-index: 30; pointer-events: none; animation: animImpacto 0.3s ease-out forwards; }

@keyframes animExplosao {
    0% { width: 20px; height: 20px; opacity: 1; transform: translate(-50%, -50%) scale(0.5); background: #f39c12; }
    50% { background: #e74c3c; }
    100% { width: 100px; height: 100px; opacity: 0; transform: translate(-50%, -50%) scale(1.5); background: #c0392b; border-radius: 50%; }
}
.fire-effect { position: absolute; filter: blur(4px); z-index: 30; pointer-events: none; animation: animExplosao 0.4s ease-out forwards; }

@keyframes animCura {
    0% { transform: translate(-50%, -20%) scale(0.8); opacity: 1; }
    100% { transform: translate(-50%, -100%) scale(1.5); opacity: 0; }
}
.heal-effect { position: absolute; width: 60px; height: 60px; border-radius: 50%; z-index: 30; pointer-events: none; animation: animCura 0.6s ease-out forwards; mix-blend-mode: screen; }

@keyframes animTrevas {
    0% { width: 40px; height: 40px; opacity: 0; transform: translate(-50%, -50%) rotate(0deg); }
    50% { opacity: 0.8; }
    100% { width: 90px; height: 90px; opacity: 0; transform: translate(-50%, -50%) rotate(90deg); border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%; }
}
.dark-effect { position: absolute; background: rgba(142, 68, 173, 0.7); filter: blur(5px); z-index: 30; pointer-events: none; animation: animTrevas 0.6s ease-out forwards; }

/* ==========================================
   HUD E INTERFACE MODERNAS
========================================== */
.modern-font { font-family: 'Poppins', sans-serif; }

.modern-hud {
    position: absolute;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 8px;
    z-index: 20; /* Garante que fique sobre o sprite se necessário */
}

#hud-monstro { 
    top: 10px; 
    left: 10px; 
    width: 150px; 
    border-top: 2px solid #e74c3c; 
}
#sprite-mob {
    position: absolute !important;
    bottom: 120px !important; 
    z-index: 5;
}

#hud-jogador {
    background: rgba(7, 10, 20, 0.95) !important;
    border: 1.5px solid #1e293b !important;
    border-top: 2px solid #3b82f6 !important; /* Brilho de destaque */
    padding: 10px !important;
    box-shadow: 0 10px 25px rgba(0,0,0,0.6) !important;
    width: 160px !important;
}

.hud-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; border-bottom: 1px solid #1e293b; padding-bottom: 4px; }
.hud-name { font-size: 0.8em; font-weight: 800; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 75%; }
.hud-level { font-size: 0.6em; color: #cbd5e1; font-weight: 800; background: rgba(255,255,255,0.1); padding: 1px 4px; border-radius: 4px; }

.hud-bar-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.hud-bar-label { font-size: 0.65em; font-weight: 800; letter-spacing: 0.5px; }
.label-hp { color: #ef4444; }
.label-mp { color: #3b82f6; }

.hud-bar-bg {
    height: 14px !important;
    background: #000 !important;
    border-radius: 4px !important;
    border: 1px solid #334155 !important;
    position: relative;
}

.hud-bar-label-inner {
    position: absolute;
    width: 100%;
    text-align: center;
    font-size: 0.65em !important;
    font-weight: 900;
    line-height: 12px;
    text-shadow: 1px 1px 2px #000;
    z-index: 2;
}

.hud-hp-fill { height: 100%; background: linear-gradient(90deg, #ef4444, #b91c1c); transition: width 0.3s ease; }
.hud-mp-fill { height: 100%; background: linear-gradient(90deg, #3b82f6, #1d4ed8); transition: width 0.3s ease; }

.modern-btn {
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    border: 1px solid #334155;
    border-radius: 6px;
    padding: 8px 5px; 
    font-size: 0.85em; 
    color: #f8fafc;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    transition: all 0.2s ease;
}
.modern-btn:active:not(:disabled) { transform: translateY(2px); border-color: #64748b; }
.btn-atk { border-bottom: 2px solid #ef4444; }
.btn-mag { border-bottom: 2px solid #8b5cf6; }
.btn-bag { border-bottom: 2px solid #f59e0b; }
.btn-run { border-bottom: 2px solid #64748b; }

/* ==========================================
   ANIMAÇÃO DE LEVEL UP (MAPA/COMBATE)
========================================== */
.animacao-level-up {
    position: fixed; /* Fixed garante que fique por cima do canvas do Phaser */
    color: #FFD700;
    font-weight: 900;
    font-size: 32px;
    font-family: 'Cinzel', serif;
    text-shadow: 2px 2px 0 #000, 0 0 10px #FFA500, 0 0 20px #FF4500;
    pointer-events: none;
    z-index: 999999;
    animation: subirEDesaparecer 2.5s ease-out forwards;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    white-space: nowrap;
}
@keyframes subirEDesaparecer {
    0% { transform: translate(-50%, 50px) scale(0.5); opacity: 0; filter: brightness(2); }
    20% { transform: translate(-50%, -20px) scale(1.1); opacity: 1; filter: brightness(1.2); }
    40% { transform: translate(-50%, -25px) scale(1); opacity: 1; }
    100% { transform: translate(-50%, -120px) scale(0.9); opacity: 0; }
}
/* Container de Recompensas Animado */
.log-recompensas {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 10px;
    animation: slideUpFade 0.5s ease-out forwards;
}

@keyframes slideUpFade {
    0% { opacity: 0; transform: translateY(20px); }
    100% { opacity: 1; transform: translateY(0); }
}

.item-recompensa {
    background: rgba(255, 255, 255, 0.05);
    padding: 5px 12px;
    border-radius: 20px;
    border: 1px solid rgba(241, 196, 15, 0.3);
    box-shadow: 0 0 10px rgba(241, 196, 15, 0.1);
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: bold;
}

@keyframes shake {
    0% { transform: translate(1px, 1px) rotate(0deg); }
    20% { transform: translate(-3px, 0px) rotate(-1deg); }
    40% { transform: translate(3px, 2px) rotate(1deg); }
    100% { transform: translate(0, 0) rotate(0deg); }
}
.shake-animation { animation: shake 0.2s double; }

/* Efeito de brilho pulsante quando o Boss está com pouca vida */
@keyframes bossLowHealth {
    0% { filter: drop-shadow(0 0 2px #ef4444); }
    50% { filter: drop-shadow(0 0 8px #ef4444); }
    100% { filter: drop-shadow(0 0 2px #ef4444); }
}

.boss-bar-low {
    animation: bossLowHealth 1s infinite;
}

/* Transição suave para a barra de vida */
#bar-hp-mob {
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.3);
}

/* ==========================================
   ANIMAÇÃO DE RESPIRAÇÃO (IDLE SPRITES)
========================================== */
@keyframes respiracao_rpg {
    0% { transform: scaleY(1) translateY(0); }
    100% { transform: scaleY(0.97) translateY(2px); }
}

#sprite-player, #sprite-mob {
    animation: respiracao_rpg 1.5s infinite alternate ease-in-out;
    transform-origin: bottom center; /* Garante que os pés ficam no chão */
}
#combat-log-box {
    /* Cores padrão do perfil: Fundo muito escuro com leve transparência */
    background: rgba(10, 10, 10, 0.95) !important;
    backdrop-filter: blur(8px);
    
    /* Borda alinhada com os temas do botão/perfil (Cinza escuro ou Dourado escuro) */
    border: 1.5px solid #2d2d2d !important;
    border-top: 2px solid #8B0000 !important; /* Destaque no topo em vermelho sangue */
    border-radius: 8px !important;
    
    padding: 15px !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.7);
    min-height: 65px !important;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center; /* Centraliza o texto */
    text-align: center;
}

#log-texto-1 {
    font-family: 'Cinzel', serif;
    font-size: 1.15em; /* Aumentado ligeiramente já que a linha 2 sumiu */
    letter-spacing: 1px;
    text-shadow: 1px 1px 2px #000; /* Legibilidade alta */
    font-weight: bold;
    color: #e0e0e0; /* Cor base da fonte quase branca */
}

#log-texto-2 {
    display: none; /* Esconde completamente a linha 2 para garantir a limpeza */
}

/* Combate: arena flexível e painel legível em telas pequenas. */
body.combate-aberto #btn-painel-gm { display:none !important; pointer-events:none !important; }
#tela-combate-global { overscroll-behavior:contain; isolation:isolate; }
#combate-arena { min-height:0; overflow-y:auto; overscroll-behavior:contain; }
/* Cenários 1440×1080: a arena mantém 4:3, sem crescimento vertical do flex. */
#tela-combate-global #arena-box { flex:0 0 auto; aspect-ratio:4 / 3; min-height:0; height:auto !important; max-height:none; border:0 !important; border-radius:0 !important; background-size:contain; background-position:center; background-repeat:no-repeat; }
#tela-combate-global .combate-painel { box-sizing:border-box; flex:1 0 210px; min-height:210px; padding:12px !important; gap:10px !important; border:0 !important; border-top:1px solid #ffffff15 !important; background:linear-gradient(160deg,#152033,#090f1d) !important; }
#tela-combate-global #combat-log-box { padding:12px !important; min-height:64px !important; background:#080f1dcc !important; border:1px solid #334155 !important; border-radius:12px !important; box-shadow:none; }
#tela-combate-global #log-texto-1 { font:600 14px/1.4 'Segoe UI',Arial,sans-serif; letter-spacing:0; }
#tela-combate-global #log-texto-2 { display:block; font:12px/1.5 'Segoe UI',Arial,sans-serif; }
#tela-combate-global .modern-btn { min-height:44px; border:1px solid #3b4961; border-radius:10px; font:600 13px 'Segoe UI',Arial,sans-serif; box-shadow:0 2px 5px #0003; }
#tela-combate-global .modern-btn:disabled { opacity:.6; cursor:default; }
#tela-combate-global #botoes-fim-batalha .modern-btn { background:#b8944a20 !important; color:#edd8a6; border-color:#ad8b49; padding:11px; }
#tela-combate-global #boss-bar-container { width:76% !important; padding:8px; border:1px solid #ffffff16; border-radius:10px; background:#0a1123bd; }
#tela-combate-global #val-hp-mob { font-size:10px !important; }
#tela-combate-global #hud-jogador { border-radius:12px !important; background:#0a1123e8 !important; padding:8px !important; }
#tela-combate-global button:focus-visible { outline:2px solid #ebcb83; outline-offset:2px; }
@media(max-height:500px) { #tela-combate-global .combate-painel { padding:7px !important; gap:6px !important; } }
/* Celular deitado: ações ao lado, mantendo o cenário inteiro e os alvos de toque. */
@media(orientation:landscape) and (min-width:600px) {
    #tela-combate-global #combate-arena { flex-direction:row !important; align-items:flex-start; }
    #tela-combate-global #arena-box { width:min(60%, calc(100dvh * 4 / 3)) !important; }
    #tela-combate-global .combate-painel { flex:1 1 0; min-width:0; min-height:100%; border-top:0 !important; border-left:1px solid #ffffff15 !important; }
}
