
/* ============================================================
   GUARDIÃO DA FLORESTA — STYLE.CSS
   Interface premium | PC e Mobile | Retrato 9:16
============================================================ */

:root {
    --gold: #ffcc55;
    --gold-light: #fff0b0;
    --gold-dark: #a96816;
    --cyan: #00e5d0;
    --red: #ff414b;
    --glass: rgba(9, 17, 29, 0.78);

    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-top: env(safe-area-inset-top, 0px);

    --button-shadow:
        0 8px 22px rgba(0, 0, 0, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.35);

    --button-transition:
        transform 0.18s ease,
        box-shadow 0.18s ease,
        filter 0.18s ease,
        border-color 0.18s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

html,
body {
    width: 100%;
    height: 100%;
    min-height: 100%;
    overflow: hidden;
    position: fixed;
    inset: 0;
    background: #050811;
    color: #fff;
    overscroll-behavior: none;
    touch-action: manipulation;
}

/* RENDERIZADOR */

#game-container {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    overflow: hidden;
    z-index: 1;
    background: #050811;
}

#game-container canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
    outline: none;
    touch-action: none;
}

/* HUD */

#ui-overlay {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    z-index: 10;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding:
        calc(18px + var(--safe-top))
        20px
        calc(18px + var(--safe-bottom));
}

.hud-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    width: 100%;
}

.stat-box {
    background: linear-gradient(
        145deg,
        rgba(19, 31, 49, 0.92),
        rgba(5, 12, 23, 0.88)
    );
    border: 1px solid rgba(255, 204, 85, 0.48);
    padding: 11px 17px;
    border-radius: 12px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow:
        0 8px 24px rgba(0, 0, 0, 0.35),
        inset 0 1px rgba(255, 255, 255, 0.08);
    pointer-events: auto;
}

.stat-label {
    font-size: 10px;
    font-weight: 900;
    letter-spacing: 1.6px;
    color: var(--gold);
    margin-bottom: 6px;
    display: block;
    text-transform: uppercase;
}

.health-bar-container {
    width: 180px;
    height: 14px;
    background: rgba(35, 5, 12, 0.95);
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid rgba(255, 65, 75, 0.55);
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.6);
}

.health-bar-fill {
    height: 100%;
    background: linear-gradient(
        90deg,
        #d91f35,
        #ff414b,
        #ff9955
    );
    border-radius: inherit;
    transition: width 0.2s ease;
    box-shadow: 0 0 12px rgba(255, 65, 75, 0.55);
}

.level-badge {
    font-weight: 900;
    color: var(--cyan);
    text-shadow: 0 0 12px rgba(0, 255, 204, 0.55);
    font-size: 14px;
    text-align: center;
}

.score-text {
    font-size: 13px;
    color: #fff0bd;
    text-align: center;
    margin-top: 5px;
    font-weight: 700;
}

/* BARRA DO CHEFE */

.boss-bar-wrapper {
    align-self: center;
    margin-bottom: 20px;
    background: rgba(25, 5, 10, 0.91);
    border: 1px solid rgba(255, 51, 51, 0.85);
    padding: 12px 24px;
    border-radius: 13px;
    text-align: center;
    width: 60%;
    max-width: 600px;
    box-shadow:
        0 0 24px rgba(255, 0, 0, 0.18),
        inset 0 1px rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(10px);
}

.boss-title {
    color: #ff5555;
    font-weight: 900;
    letter-spacing: 2px;
    font-size: 14px;
    margin-bottom: 7px;
    text-shadow: 0 0 10px rgba(255, 0, 0, 0.4);
}

.boss-bar-container {
    width: 100%;
    height: 18px;
    background: #100000;
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid rgba(255, 80, 80, 0.3);
}

.boss-bar-fill {
    height: 100%;
    background: linear-gradient(
        90deg,
        #880000,
        #ff2020,
        #ff6666
    );
    border-radius: inherit;
    transition: width 0.1s ease;
    box-shadow: 0 0 12px rgba(255, 0, 0, 0.55);
}

/* MODAIS */

.screen-modal {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    background: rgba(3, 7, 14, 0.88);
    backdrop-filter: blur(13px);
    -webkit-backdrop-filter: blur(13px);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    padding:
        calc(20px + var(--safe-top))
        18px
        calc(20px + var(--safe-bottom));
}

.modal-card {
    position: relative;
    background: linear-gradient(
        145deg,
        rgba(23, 36, 55, 0.98),
        rgba(7, 13, 24, 0.98)
    );
    border: 1px solid rgba(255, 190, 65, 0.8);
    padding: 38px;
    border-radius: 20px;
    text-align: center;
    max-width: 450px;
    width: 90%;
    box-shadow:
        0 25px 80px rgba(0, 0, 0, 0.7),
        0 0 35px rgba(255, 170, 0, 0.12),
        inset 0 1px rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

.modal-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 12%;
    width: 76%;
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 222, 150, 0.9),
        transparent
    );
}

.modal-card.danger {
    border-color: rgba(255, 65, 75, 0.85);
}

.modal-card.success {
    border-color: rgba(0, 255, 170, 0.8);
}

.title-main {
    font-size: 28px;
    color: var(--gold);
    margin-bottom: 8px;
    letter-spacing: 2px;
    font-weight: 900;
    text-shadow: 0 0 18px rgba(255, 190, 65, 0.25);
}

.subtitle {
    color: #a9c3ed;
    font-size: 14px;
    margin-bottom: 22px;
    line-height: 1.5;
}

.instructions {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.07);
    padding: 16px;
    border-radius: 12px;
    text-align: left;
    font-size: 13px;
    line-height: 1.7;
    margin-bottom: 25px;
    color: #e0e7f2;
}

/* BOTÕES PRINCIPAIS */

.btn-primary,
.btn-secondary {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    min-height: 48px;
    padding: 14px 32px;
    background: linear-gradient(
        180deg,
        #ffe9a9 0%,
        #ffd16b 22%,
        #e9a83e 65%,
        #bd791f 100%
    );
    border: 1px solid rgba(255, 239, 190, 0.9);
    border-radius: 11px;
    color: #251707;
    font-size: 13px;
    font-weight: 900;
    letter-spacing: 1.4px;
    text-transform: uppercase;
    cursor: pointer;
    touch-action: manipulation;
    box-shadow:
        0 4px 0 #805018,
        0 9px 24px rgba(226, 157, 48, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.85),
        inset 0 -2px 4px rgba(112, 66, 12, 0.18);
    transition: var(--button-transition);
    margin: 5px;
}

.btn-primary::before,
.btn-secondary::before {
    content: "";
    position: absolute;
    top: 0;
    left: -120%;
    width: 65%;
    height: 100%;
    transform: skewX(-25deg);
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.4),
        transparent
    );
    transition: left 0.65s ease;
    pointer-events: none;
}

.btn-primary::after,
.btn-secondary::after {
    content: "";
    position: absolute;
    inset: 3px;
    border: 1px solid rgba(255, 255, 255, 0.27);
    border-radius: 8px;
    pointer-events: none;
}

.btn-primary:hover::before,
.btn-secondary:hover::before {
    left: 150%;
}

.btn-primary:hover,
.btn-secondary:hover {
    transform: translateY(-2px);
    filter: brightness(1.08);
    box-shadow:
        0 6px 0 #805018,
        0 13px 30px rgba(255, 180, 55, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.btn-primary:active,
.btn-secondary:active {
    transform: translateY(3px) scale(0.985);
    filter: brightness(0.96);
    box-shadow:
        0 1px 0 #805018,
        0 4px 12px rgba(255, 170, 0, 0.15),
        inset 0 2px 5px rgba(112, 66, 12, 0.2);
}

/* BOTÕES HUD */

.btn-hud {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    min-height: 36px;
    padding: 8px 16px;
    background: linear-gradient(
        145deg,
        rgba(49, 72, 99, 0.96),
        rgba(15, 29, 48, 0.98)
    );
    border: 1px solid rgba(160, 197, 231, 0.48);
    border-radius: 9px;
    color: #edf6ff;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.9px;
    text-transform: uppercase;
    cursor: pointer;
    touch-action: manipulation;
    box-shadow:
        0 4px 12px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.18);
    transition: var(--button-transition);
    margin: 5px;
}

.btn-hud:hover {
    transform: translateY(-2px);
    border-color: rgba(205, 228, 255, 0.85);
    background: linear-gradient(
        145deg,
        rgba(65, 96, 129, 0.98),
        rgba(23, 43, 68, 0.98)
    );
    box-shadow:
        0 7px 18px rgba(0, 0, 0, 0.35),
        0 0 14px rgba(110, 180, 255, 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-hud:active {
    transform: translateY(2px) scale(0.97);
    filter: brightness(1.2);
}

/* CONTROLES MOBILE */

#mobile-controls {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    z-index: 20;
    pointer-events: none;
}

.dpad {
    display: contents;
    pointer-events: none;
}

/* DIRECIONAIS */

.dpad .btn-touch {
    position: absolute;
    bottom: calc(23px + var(--safe-bottom));
    width: 68px;
    height: 68px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    border-radius: 23px;
    font-size: 25px;
    font-weight: 900;
    color: #eaf5ff;
    border: 1px solid rgba(132, 197, 255, 0.85);
    background:
        radial-gradient(
            circle at 30% 18%,
            rgba(255, 255, 255, 0.3),
            transparent 48%
        ),
        linear-gradient(
            145deg,
            #345b83 0%,
            #193753 48%,
            #091728 100%
        );
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    touch-action: none;
    cursor: pointer;
    box-shadow:
        0 6px 0 #071321,
        0 12px 24px rgba(0, 0, 0, 0.5),
        0 0 20px rgba(61, 159, 255, 0.2),
        inset 0 1px 2px rgba(255, 255, 255, 0.45),
        inset 0 -5px 10px rgba(0, 0, 0, 0.3);
    transition: var(--button-transition);
}

#btn-m-left {
    left: max(18px, env(safe-area-inset-left));
}

#btn-m-right {
    right: max(18px, env(safe-area-inset-right));
}

.dpad .btn-touch::before {
    content: "";
    position: absolute;
    inset: 5px;
    border-radius: 18px;
    border: 1px solid rgba(185, 220, 255, 0.24);
    pointer-events: none;
}

.dpad .btn-touch:active {
    transform: translateY(4px) scale(0.94);
    filter: brightness(1.35);
    box-shadow:
        0 2px 0 #071321,
        0 5px 12px rgba(0, 0, 0, 0.45),
        0 0 24px rgba(61, 159, 255, 0.35),
        inset 0 3px 9px rgba(0, 0, 0, 0.4);
}

/* BOTÕES DE AÇÃO */

.actions {
    position: absolute;
    right: max(18px, env(safe-area-inset-right));
    bottom: calc(108px + var(--safe-bottom));
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 12px;
    pointer-events: auto;
}

.actions .btn-touch {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    width: 66px;
    height: 66px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 2px;
    border-radius: 21px;
    font-size: 24px;
    font-weight: 900;
    letter-spacing: 0.3px;
    cursor: pointer;
    touch-action: none;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    transition: var(--button-transition);
}

.actions .btn-touch span {
    font-size: 8px;
    font-weight: 900;
    letter-spacing: 0.7px;
    line-height: 1;
}

.actions .btn-touch::before {
    content: "";
    position: absolute;
    inset: 4px;
    border: 1px solid rgba(255, 255, 255, 0.24);
    border-radius: 16px;
    pointer-events: none;
}

.actions .btn-touch::after {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 70%;
    height: 100%;
    transform: skewX(-25deg);
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent
    );
    transition: left 0.55s ease;
    pointer-events: none;
}

.actions .btn-touch:active::after {
    left: 140%;
}

/* ATAQUE */

.actions #btn-m-attack {
    width: 76px;
    height: 76px;
    border: 1px solid rgba(255, 183, 158, 0.95);
    border-radius: 24px;
    color: #fff7f3;
    text-shadow:
        0 0 8px rgba(255, 180, 150, 0.75),
        0 2px 4px rgba(0, 0, 0, 0.7);
    background:
        radial-gradient(
            circle at 30% 18%,
            rgba(255, 255, 255, 0.35),
            transparent 46%
        ),
        linear-gradient(
            145deg,
            #ff8065 0%,
            #d83c36 48%,
            #681b26 100%
        );
    box-shadow:
        0 6px 0 #46131d,
        0 12px 23px rgba(0, 0, 0, 0.48),
        0 0 20px rgba(255, 65, 55, 0.27),
        inset 0 1px 3px rgba(255, 255, 255, 0.42),
        inset 0 -5px 10px rgba(0, 0, 0, 0.24);
}

/* PULO */

.actions #btn-m-jump {
    border: 1px solid rgba(133, 255, 235, 0.9);
    color: #edfffc;
    background:
        radial-gradient(
            circle at 30% 18%,
            rgba(255, 255, 255, 0.35),
            transparent 46%
        ),
        linear-gradient(
            145deg,
            #54e4d0 0%,
            #159f98 48%,
            #10434b 100%
        );
    text-shadow: 0 0 10px rgba(112, 255, 234, 0.6);
    box-shadow:
        0 6px 0 #0b333b,
        0 12px 23px rgba(0, 0, 0, 0.45),
        0 0 19px rgba(0, 255, 210, 0.24),
        inset 0 1px 3px rgba(255, 255, 255, 0.42),
        inset 0 -5px 10px rgba(0, 0, 0, 0.25);
}

/* MAGIA */

.actions #btn-m-magic {
    width: 70px;
    height: 70px;
    border: 1px solid rgba(226, 177, 255, 0.95);
    border-radius: 22px;
    color: #fff1ff;
    background:
        radial-gradient(
            circle at 30% 18%,
            rgba(255, 255, 255, 0.4),
            transparent 46%
        ),
        linear-gradient(
            145deg,
            #c58aff 0%,
            #803ed2 48%,
            #32105e 100%
        );
    text-shadow:
        0 0 9px rgba(230, 183, 255, 0.9),
        0 2px 4px rgba(0, 0, 0, 0.5);
    box-shadow:
        0 6px 0 #251044,
        0 12px 23px rgba(0, 0, 0, 0.48),
        0 0 23px rgba(177, 91, 255, 0.32),
        inset 0 1px 3px rgba(255, 255, 255, 0.43),
        inset 0 -5px 10px rgba(0, 0, 0, 0.25);
}

/* EFEITOS DE TOQUE */

.actions .btn-touch:active {
    transform: translateY(4px) scale(0.94);
    filter: brightness(1.3);
}

.actions #btn-m-attack:active {
    border-color: #fff0e7;
    box-shadow:
        0 2px 0 #46131d,
        0 5px 13px rgba(0, 0, 0, 0.4),
        0 0 26px rgba(255, 65, 55, 0.5),
        inset 0 3px 9px rgba(0, 0, 0, 0.3);
}

.actions #btn-m-jump:active {
    border-color: #e1fff9;
    box-shadow:
        0 2px 0 #0b333b,
        0 5px 13px rgba(0, 0, 0, 0.4),
        0 0 26px rgba(0, 255, 210, 0.45),
        inset 0 3px 9px rgba(0, 0, 0, 0.3);
}

.actions #btn-m-magic:active {
    border-color: #f5ddff;
    box-shadow:
        0 2px 0 #251044,
        0 5px 13px rgba(0, 0, 0, 0.4),
        0 0 30px rgba(177, 91, 255, 0.6),
        inset 0 3px 9px rgba(0, 0, 0, 0.3);
}

/* ESTADOS */

.hidden {
    display: none !important;
}

button {
    -webkit-appearance: none;
    appearance: none;
    outline: none;
}

button:focus-visible {
    outline: 2px solid var(--gold-light);
    outline-offset: 3px;
}

/* CELULAR — RETRATO */

@media (max-width: 768px) {

    html,
    body {
        width: 100%;
        height: 100%;
        height: 100dvh;
        overflow: hidden;
    }

    #game-container {
        width: 100%;
        height: 100%;
        height: 100dvh;
    }

    #ui-overlay {
        height: 100%;
        height: 100dvh;
        padding:
            calc(10px + var(--safe-top))
            10px
            calc(10px + var(--safe-bottom));
    }

    .hud-top {
        gap: 6px;
    }

    .stat-box {
        padding: 8px 10px;
        border-radius: 10px;
    }

    .stat-label {
        font-size: 9px;
        letter-spacing: 1px;
    }

    .health-bar-container {
        width: clamp(85px, 30vw, 150px);
        height: 11px;
    }

    .level-badge {
        font-size: 11px;
    }

    .score-text {
        font-size: 11px;
    }

    .boss-bar-wrapper {
        width: 88%;
        padding: 9px 14px;
        margin-bottom: 12px;
    }

    .boss-title {
        font-size: 11px;
    }

    .boss-bar-container {
        height: 13px;
    }

    .modal-card {
        width: 100%;
        max-width: 430px;
        padding: 27px 20px;
        border-radius: 17px;
    }

    .title-main {
        font-size: clamp(20px, 6vw, 27px);
    }

    .subtitle {
        font-size: 12px;
        margin-bottom: 16px;
    }

    .instructions {
        padding: 12px;
        font-size: 12px;
        margin-bottom: 18px;
    }

    .btn-primary,
    .btn-secondary {
        width: min(100%, 280px);
        min-height: 48px;
        font-size: 12px;
    }
}

/* CELULARES PEQUENOS */

@media (max-width: 380px) {
    .stat-box {
        padding: 7px 8px;
    }

    .actions .btn-touch span {
        font-size: 6px;
    }
}

/* CELULAR DEITADO */

@media (max-width: 900px) and (orientation: landscape) {

    #ui-overlay {
        padding: 8px 14px;
    }

    .modal-card {
        padding: 18px 25px;
    }

    .instructions {
        margin-bottom: 12px;
        padding: 9px;
    }
}

/* COMPUTADOR */

@media (min-width: 1025px) {
    #mobile-controls {
        display: none;
    }
}

/* REDUÇÃO DE MOVIMENTO */

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}

/* ============================================================
   POSICIONAMENTO DEFINITIVO DOS CONTROLES MOBILE

   ESQUERDA | PULO | ATAQUE | MAGIA | DIREITA
============================================================ */

@media (max-width: 1024px) {

    #mobile-controls {
        display: flex;
        flex-direction: row;
        align-items: flex-end;
        justify-content: flex-start;

        padding:
            0
            max(8px, env(safe-area-inset-right))
            calc(17px + var(--safe-bottom))
            max(8px, env(safe-area-inset-left));

        pointer-events: none;
    }

    /*
       Os botões do dpad participam
       diretamente da linha de controles.
    */

    #mobile-controls .dpad {
        display: contents;
    }

    /* ESQUERDA */

    #mobile-controls #btn-m-left {
        position: relative;
        inset: auto;
        order: 1;
        flex: 0 0 auto;
        pointer-events: auto;
    }

    /* GRUPO DE AÇÕES AO LADO DA ESQUERDA */

    #mobile-controls .actions {
        position: static;
        order: 2;

        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;

        gap: clamp(3px, 1vw, 8px);

        flex: 0 1 auto;
        min-width: 0;

        margin-left: clamp(5px, 1.5vw, 12px);
        margin-right: 0;

        pointer-events: auto;
    }

    /* ORDEM DOS TRÊS BOTÕES */

    #mobile-controls .actions #btn-m-jump {
        order: 1;
    }

    #mobile-controls .actions #btn-m-attack {
        order: 2;
    }

    #mobile-controls .actions #btn-m-magic {
        order: 3;
    }

    /* DIREITA */

    #mobile-controls #btn-m-right {
        position: relative;
        inset: auto;
        order: 3;
        flex: 0 0 auto;
        margin-left: auto;
        pointer-events: auto;
    }

    /* TAMANHOS DOS DIRECIONAIS */

    #mobile-controls .dpad .btn-touch {
        width: clamp(40px, 14vw, 58px);
        height: clamp(42px, 14vw, 58px);
    }

    /* TAMANHOS DAS AÇÕES */

    #mobile-controls .actions .btn-touch {
        width: clamp(39px, 12.5vw, 54px);
        height: clamp(42px, 12.5vw, 54px);
        flex-shrink: 1;
    }

    #mobile-controls .actions #btn-m-attack {
        width: clamp(43px, 13.5vw, 58px);
        height: clamp(46px, 13.5vw, 58px);
    }
}

/* AJUSTE PARA CELULARES PEQUENOS */

@media (max-width: 380px) {

    #mobile-controls {
        padding-left: max(5px, env(safe-area-inset-left));
        padding-right: max(5px, env(safe-area-inset-right));
        padding-bottom: calc(12px + var(--safe-bottom));
    }

    #mobile-controls .dpad .btn-touch {
        width: 40px;
        height: 44px;
    }

    #mobile-controls .actions {
        gap: 3px;
        margin-left: 5px;
    }

    #mobile-controls .actions .btn-touch {
        width: 39px;
        height: 44px;
        border-radius: 13px;
        font-size: 19px;
    }

    #mobile-controls .actions #btn-m-attack {
        width: 43px;
        height: 47px;
    }

    #mobile-controls .actions .btn-touch span {
        font-size: 7px;
    }
}
