* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

html,
body {
    height: 100%;
    height: 100dvh;
    width: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    /* Trava o scroll do body */
    touch-action: none;
    /* Previne gestos indesejados no root */
    overscroll-behavior: none;
}

body {
    font-family: monospace;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #0a0f1f;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 20px 20px;
}

#game-app {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 480px;
    height: 100%;
    height: 100dvh;
    background: #0d0d1a;
    border: 2px solid #5594a8;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.8);
    position: relative;
    overflow: hidden;
}

#top-header {
    background-color: #003935;
    border-bottom: 2px solid #5594a8;
    color: white;
    text-shadow: 1px 1px 0px #3C7A83;
    padding: 8px;


}

#top-header-game {
    background-color: rgb(13 13 26);
    color: rgb(156 163 175);
    font-family: 'Press Start 2P', cursive;
    font-size: 10px;
    padding: 8px;
    border-bottom: 2px solid #5594a8;

}

.page-content {
    color: white;
    /* text-shadow: 1px 1px 0px #3C7A83; */
}

#top-header::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(rgba(255, 255, 255, 0.2) 1px, transparent 1px);
    background-size: 3px 3px;
    opacity: 0.2;
    pointer-events: none;
}

#top-header-div {}

#main-window {
    background-color: #112257;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    /* padding: 8px; */

    /* --- ADICIONE ESTAS DUAS LINHAS --- */
    justify-content: center;
    /* Centraliza a arena horizontalmente (opcional, já que você usa margin-left: auto) */
    /* align-items: center; */
    /* Centraliza a arena verticalmente E impede que ela estique! */
    min-height: 0;
}

#main-window::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px);
    background-size: 100% 3px;
    opacity: 0.3;
    pointer-events: none;
}

#bottom-header {
    height: auto;
    min-height: 50px;
    display: flex;
    justify-content: space-around;
    align-items: center;

    background-color: #002b36;
    border-top: 2px solid #5594a8;

    position: relative;
    padding-bottom: env(safe-area-inset-bottom);
}

/* grid opcional estilo digital */
#bottom-header::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(85, 148, 168, 0.1) 1px, transparent 1px);
    background-size: 100% 3px;
    opacity: 0.2;
    pointer-events: none;
}

.nav-item {
    flex: 1;
    height: 100%;

    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;

    font-size: 10px;
    text-transform: uppercase;
    color: #7fbfd4;

    gap: 2px;

    cursor: pointer;
    transition: all 0.15s ease;
}

/* ícone */
.nav-item i {
    font-size: 18px;
}

/* label */
.nav-item span {
    font-size: 9px;
}

/* hover (desktop) */
.nav-item:hover {
    background-color: rgba(85, 148, 168, 0.15);
}

/* clique */
.nav-item:active {
    transform: scale(0.95);
}

/* estado ativo (ESSENCIAL) */
.nav-item.active {
    color: #3ea7dd;
    background-color: rgba(62, 167, 221, 0.15);
}

/* glow no ativo */
.nav-item.active i {
    text-shadow: 0 0 6px #3ea7dd;
}

.black-stroke {
    text-shadow: rgb(0, 0, 0) 1px 0px 0px, rgb(0, 0, 0) 0.540302px 0.841471px 0px, rgb(0, 0, 0) -0.416147px 0.909297px 0px, rgb(0, 0, 0) -0.989992px 0.14112px 0px, rgb(0, 0, 0) -0.653644px -0.756802px 0px, rgb(0, 0, 0) 0.283662px -0.958924px 0px, rgb(0, 0, 0) 0.96017px -0.279415px 0px;
}

.black-stroke-2 {
    text-shadow: rgb(0, 0, 0) 2px 0px 0px, rgb(0, 0, 0) 1.75517px 0.958851px 0px, rgb(0, 0, 0) 1.0806px 1.68294px 0px, rgb(0, 0, 0) 0.141474px 1.99499px 0px, rgb(0, 0, 0) -0.832294px 1.81859px 0px, rgb(0, 0, 0) -1.60229px 1.19694px 0px, rgb(0, 0, 0) -1.97998px 0.28224px 0px, rgb(0, 0, 0) -1.87291px -0.701566px 0px, rgb(0, 0, 0) -1.30729px -1.5136px 0px, rgb(0, 0, 0) -0.421592px -1.95506px 0px, rgb(0, 0, 0) 0.567324px -1.91785px 0px, rgb(0, 0, 0) 1.41734px -1.41108px 0px, rgb(0, 0, 0) 1.92034px -0.558831px 0px;
}

#battle-arena {
    /* Coloque o caminho da imagem de floresta que você enviou aqui */
    /* background-image: url('https://i.imgur.com/QBoQu1z.png'); */
    background-color: #000;

    /* background-size: cover; funciona perfeitamente agora, 
               pois a div terá o exato mesmo formato da imagem */
    background-size: cover;
    background-position: top;
    background-repeat: no-repeat;

    width: 100%;
    max-width: 400px;

    /* --- A MÁGICA ACONTECE AQUI --- */
    /* Isso avisa ao navegador: "A cada 800px de largura, tenha 480px de altura" */
    aspect-ratio: 800 / 380;

    /* REMOVA o min-height e o max-height que estavam aqui! */

    margin-left: auto;
    margin-right: auto;

    /* O segredo para posicionar os monstros livremente: */
    position: relative;
    z-index: 2;

    /* Estilo extra (opcional) para dar cara de janela de jogo */
    border: 2px solid #5594a8;
    border-radius: 4px;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.4);
    /* Sombreamento interno */
    overflow: hidden;
    /* Impede que algo vaze para fora da arena */
}

#battle-hud {
    width: 100%;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
    position: relative;
    border: 2px solid #5594a8;
    border-radius: 4px;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.4);
    overflow: hidden;
    display: flex;
    justify-content: space-around;
    padding: 4px;
    margin-top: 4px;
    background-color: #209689;
}

#player-digimon {
    position: absolute;
    bottom: 10px;
    /* Posiciona na parte de baixo */
    left: 15%;
    /* Posiciona na esquerda */
    z-index: 2;
    /* Garante que fique na frente (ilusão de perspectiva) */
}

#player-digimon img {
    /* Vira o monstro para a direita para encarar o inimigo */
    transform: scale(-2, 2);
    transform-origin: bottom center;
    /* MANTENHA ISSO: Garante que os pixels fiquem quadrados e perfeitos ao esticar */
    image-rendering: pixelated;
}

#enemy-digimon {
    position: absolute;
    bottom: 10px;
    /* Posiciona na parte de cima (fundo da cena) */
    right: 15%;
    /* Posiciona na direita */
    z-index: 1;
}

#enemy-digimon img {
    /* Apenas dobra o tamanho (2x) nos dois eixos */
    transform: scale(2);

    /* Cresce para cima, sem afundar no cenário */
    transform-origin: bottom center;

    /* Mantém a nitidez do pixel art */
    image-rendering: pixelated;
}

.damage-number {
    position: absolute;
    z-index: 5;
    transform: translate(-50%, -50%);
    pointer-events: none;
    font-family: 'Press Start 2P', cursive;
    font-size: 12px;
    line-height: 1;
    color: #ffef5a;
    text-shadow:
        2px 0 0 #000,
        -2px 0 0 #000,
        0 2px 0 #000,
        0 -2px 0 #000,
        2px 2px 0 #b42318;
    animation: damage-float 800ms ease-out forwards;
    will-change: transform, opacity;
}

.damage-number-miss {
    color: #d7f3ff;
    font-size: 10px;
    text-shadow:
        2px 0 0 #000,
        -2px 0 0 #000,
        0 2px 0 #000,
        0 -2px 0 #000,
        2px 2px 0 #2f5cc1;
}

@keyframes damage-float {
    0% {
        opacity: 0;
        transform: translate(-50%, -20%) scale(0.8);
    }

    15% {
        opacity: 1;
        transform: translate(-50%, -55%) scale(1.25);
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -140%) scale(1);
    }
}

/* --- MODO RESPONSIVO PARA CELULARES --- */
/* Esta regra só é ativada se a tela for menor que 600px de largura */
@media (max-width: 600px) {

    #player-digimon img {
        /* Diminui a escala de 2 para 1.5 (mantendo o valor negativo no X para espelhar) */
        transform: scale(-1.5, 1.5);
    }

    #enemy-digimon img {
        /* Diminui a escala do inimigo de 2 para 1.5 */
        transform: scale(1.5);
    }

    /* Dica extra: você também pode ajustar a posição deles no celular se achar necessário */
    #player-digimon {
        /* bottom: 10%;
                left: 10%; */
    }

    #enemy-digimon {
        /* bottom: 10%;
                right: 10%; */
    }
}

.battle-hud-bar {
    width: 100%;
    height: 10px;
    background-color: #595959;
    border: 1px solid black;
}

.hp-bar-fill {
    width: 70%;
    height: 8px;
    background-color: #3aab85;
}

.mp-bar-fill {
    width: 70%;
    height: 8px;
    background-color: #3db2bb;
}

.exp-bar-fill {
    width: 70%;
    height: 8px;
    background-color: #9f8eff;
}

.sp-bar-fill {
    width: 70%;
    height: 8px;
    background-color: #f8ff01;
}

.level-battle-hud {
    color: #42bcd0;
    text-shadow: rgb(47, 92, 193) 2px 0px 0px, rgb(47, 92, 193) 1.75517px 0.958851px 0px, rgb(47, 92, 193) 1.0806px 1.68294px 0px, rgb(47, 92, 193) 0.141474px 1.99499px 0px, rgb(47, 92, 193) -0.832294px 1.81859px 0px, rgb(47, 92, 193) -1.60229px 1.19694px 0px, rgb(47, 92, 193) -1.97998px 0.28224px 0px, rgb(47, 92, 193) -1.87291px -0.701566px 0px, rgb(47, 92, 193) -1.30729px -1.5136px 0px, rgb(47, 92, 193) -0.421592px -1.95506px 0px, rgb(47, 92, 193) 0.567324px -1.91785px 0px, rgb(47, 92, 193) 1.41734px -1.41108px 0px, rgb(47, 92, 193) 1.92034px -0.558831px 0px;
}

.pixelated {
    image-rendering: pixelated;
}

.font-start {
    font-family: 'Press Start 2P', cursive;
}

#load-digimon-modal {
    width: 100%;
    height: 100%;
    position: absolute;
    left: 0;
    top: 0;
    /* transform: translate(-50%, -50%); */
    background-color: #0d0d1a;
    overflow: auto;
    border: 3px solid black;
}

#load-item-modal {
    width: 100%;
    height: 100%;
    position: absolute;
    left: 0;
    top: 0;
    /* transform: translate(-50%, -50%); */
    background-color: #0d0d1a;
    overflow: auto;
    border: 3px solid black;
}

.fake-window-header {
    background: #5594a8;
    color: #0d0d1a;
    padding: 5px 10px;
    /* font-size: 10px; */
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

/* ─── More Drawer ─────────────────────────────── */
#more-drawer-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 200;
    backdrop-filter: blur(2px);
}

#more-drawer-overlay.open {
    display: block;
}

#more-drawer {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%) translateY(100%);
    width: 100%;
    max-width: 480px;
    background: #0a0a18;
    border-top: 2px solid #5594a8;
    border-left: 2px solid #5594a8;
    border-right: 2px solid #5594a8;
    z-index: 201;
    padding: 0 16px 24px;
    transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.7);
}

#more-drawer.open {
    transform: translateX(-50%) translateY(0%);
}

#more-drawer-handle {
    width: 40px;
    height: 4px;
    background: #5594a8;
    border-radius: 2px;
    margin: 10px auto 14px;
    opacity: 0.6;
}

.more-drawer-title {
    font-family: 'Press Start 2P', cursive;
    font-size: 8px;
    color: #5594a8;
    letter-spacing: 3px;
    text-align: center;
    margin-bottom: 16px;
}

.more-drawer-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.more-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 4px;
    background: #0d0d1a;
    border: 1px solid #1e2d3a;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.more-item:hover,
.more-item:active {
    background: #12182a;
    border-color: #5594a8;
}

.more-item i {
    font-size: 20px;
    color: #5594a8;
}

.more-item span {
    font-family: 'Press Start 2P', cursive;
    font-size: 6px;
    color: #7fbfd4;
    text-align: center;
}

.more-item.active i {
    color: #dde57b;
}

/* When drawer is open, highlight More button */
#nav-more-btn.drawer-open i {
    color: #dde57b;
}