:root {
    --ink: #e8dcc4;
    --muted: #b8a88a;
    --gold: #d4b45a;
    --ember: #e07a3a;
    --bg: #08090d;
}

html, body {
    margin: 0;
    width: 100%;
    height: 100%;
    background: var(--bg);
    color: var(--ink);
    font-family: Outfit, sans-serif;
    overflow: hidden;
}

body {
    padding: 0 !important;
    display: block !important;
    min-height: 100dvh;
}

.lab-foot {
    position: absolute;
    bottom: calc(0.35rem + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%);
    z-index: 8;
    pointer-events: none;
    opacity: 0.4;
}

.lab-foot a {
    pointer-events: auto;
}

.game-shell {
    position: relative;
    width: 100%;
    height: 100dvh;
    min-height: 100vh;
}

#scene {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    cursor: crosshair;
}

.fade {
    position: absolute;
    inset: 0;
    background: #05060a;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.45s ease;
    z-index: 20;
}

.fade.is-active {
    opacity: 1;
}

.vignette {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 8;
    background: radial-gradient(ellipse at center, transparent 48%, rgba(0, 0, 0, 0.45) 100%);
}

.app-logo {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-family: Cinzel, serif;
    font-weight: 600;
    letter-spacing: 0.04em;
}

.brand-mark {
    opacity: 0.85;
}

.game-shell > header {
    position: absolute;
    top: calc(0.9rem + env(safe-area-inset-top, 0px));
    left: calc(1rem + env(safe-area-inset-left, 0px));
    right: calc(1rem + env(safe-area-inset-right, 0px));
    z-index: 80;
    margin: 0;
    padding: 0;
    max-width: none;
    width: auto;
    pointer-events: none;
    gap: 0.6rem;
}

.game-shell > header > * {
    pointer-events: auto;
}

.game-shell > header .back-link {
    background: rgba(8, 9, 13, 0.82);
    backdrop-filter: blur(16px);
    border-color: rgba(212, 180, 90, 0.35);
    color: var(--ink);
}

.game-shell > header .back-link:hover {
    color: var(--gold);
    border-color: var(--gold);
}

.hud {
    position: absolute;
    inset: 0;
    z-index: 12;
    pointer-events: none;
}

.hud-top {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 5.5rem 1.4rem 0;
}

.panel {
    background: linear-gradient(180deg, rgba(8, 10, 16, 0.55), rgba(8, 10, 16, 0.2));
    border: 1px solid rgba(212, 180, 90, 0.18);
    backdrop-filter: blur(8px);
    padding: 0.7rem 0.95rem;
    min-width: 10rem;
}

.hud-label {
    display: block;
    font-size: 0.68rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--gold);
    margin-bottom: 0.25rem;
}

.hearts {
    display: flex;
    gap: 0.25rem;
    color: #c94a3a;
    font-size: 1.05rem;
}

.heart.is-empty {
    opacity: 0.22;
}

.objective {
    margin: 0;
    font-size: 1.02rem;
    font-weight: 500;
    max-width: 28rem;
}

.quest-panel.is-flash .objective {
    animation: pulse 1.4s ease;
}

.objective[data-urgent="true"] {
    color: #ffd27a;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-family: Cinzel, serif;
}

.stealth {
    position: absolute;
    top: 8.5rem;
    left: 50%;
    transform: translateX(-50%);
    width: min(16rem, 70vw);
    text-align: center;
    font-size: 0.75rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--muted);
}

.stealth i {
    display: block;
    height: 4px;
    margin-top: 0.4rem;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 99px;
    overflow: hidden;
}

.stealth b {
    display: block;
    height: 100%;
    width: 0;
    background: #7ad0a0;
}

.stealth[data-danger="true"] b {
    background: #d45a3a;
}

.prompt, .toast {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    margin: 0;
}

.prompt {
    bottom: 7.5rem;
    padding: 0.45rem 0.8rem;
    background: rgba(8, 10, 16, 0.62);
    border: 1px solid rgba(232, 220, 196, 0.2);
    font-size: 0.95rem;
}

.toast {
    top: 42%;
    font-family: Cinzel, serif;
    letter-spacing: 0.12em;
    font-size: 1.15rem;
    text-shadow: 0 2px 16px #000;
}

kbd {
    display: inline-block;
    min-width: 1.2rem;
    padding: 0.1rem 0.35rem;
    margin-right: 0.15rem;
    border: 1px solid rgba(232, 220, 196, 0.35);
    font-family: Outfit, sans-serif;
    font-size: 0.78rem;
}

.dialogue {
    position: absolute;
    left: 50%;
    bottom: 2.2rem;
    transform: translateX(-50%);
    width: min(40rem, 90vw);
    text-align: center;
    pointer-events: none;
}

.speaker {
    display: block;
    font-family: Cinzel, serif;
    font-size: 0.78rem;
    letter-spacing: 0.22em;
    color: var(--gold);
    margin-bottom: 0.35rem;
}

.line {
    margin: 0;
    font-size: 1.2rem;
    line-height: 1.45;
    text-shadow: 0 2px 18px #000;
}

.hud-actions {
    position: absolute;
    right: 1.2rem;
    bottom: 1rem;
}

.fps {
    font-size: 0.7rem;
    opacity: 0.4;
}

.chapter-card {
    position: absolute;
    inset: 0;
    z-index: 15;
    display: grid;
    place-content: center;
    text-align: center;
    pointer-events: none;
}

.chapter-card h2 {
    font-family: Cinzel, serif;
    font-weight: 600;
    letter-spacing: 0.18em;
    font-size: clamp(1.4rem, 4vw, 2.4rem);
    margin: 0;
}

.overlay {
    position: absolute;
    inset: 0;
    z-index: 30;
    display: grid;
    place-items: center;
    background: linear-gradient(180deg, rgba(6, 8, 12, 0.72), rgba(6, 8, 12, 0.88));
    padding: calc(4.2rem + env(safe-area-inset-top, 0px)) 1.2rem calc(1.2rem + env(safe-area-inset-bottom, 0px));
}

.overlay[hidden],
.hud[hidden],
.chapter-card[hidden],
.prompt[hidden],
.toast[hidden],
.dialogue[hidden],
.stealth[hidden] {
    display: none !important;
}

.overlay-card {
    max-height: min(92dvh, 900px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    width: min(40rem, 100%);
    background: rgba(12, 14, 20, 0.82);
    border: 1px solid rgba(212, 180, 90, 0.22);
    padding: 2rem 1.8rem;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

.menu-head h1,
.end-card h1 {
    font-family: Cinzel, serif;
    font-weight: 700;
    line-height: 1.25;
    margin: 0.4rem 0 0.8rem;
    font-size: clamp(1.6rem, 4vw, 2.5rem);
}

.menu-head h1 span,
.end-card h1 span {
    font-weight: 500;
    color: var(--gold);
}

.eyebrow {
    letter-spacing: 0.28em;
    text-transform: uppercase;
    font-size: 0.72rem;
    color: var(--gold);
    margin: 0;
}

.lede {
    color: var(--muted);
    line-height: 1.5;
    margin: 0 0 1.4rem;
}

.menu-actions {
    display: grid;
    gap: 0.55rem;
}

.primary-button,
.ghost-button {
    font-family: Outfit, sans-serif;
    font-size: 1rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-radius: 0;
}

.primary-button {
    background: linear-gradient(180deg, #d4b45a, #b08a32);
    color: #1a140c;
    border: 0;
    font-weight: 650;
}

.ghost-button {
    background: transparent;
    color: var(--ink);
    border: 1px solid rgba(232, 220, 196, 0.28);
}

.primary-button:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.keys {
    display: grid;
    gap: 0.45rem;
    margin: 1rem 0 1.4rem;
    color: var(--muted);
}

.field {
    display: grid;
    gap: 0.35rem;
    margin-bottom: 1rem;
}

.field select,
.field input {
    font: inherit;
    padding: 0.45rem;
    background: #12141c;
    color: var(--ink);
    border: 1px solid rgba(232, 220, 196, 0.2);
}

.loading-card {
    text-align: center;
}

.loading-card h1 {
    font-family: Cinzel, serif;
    margin: 0.4rem 0 0;
}

.loading-card .sub {
    color: var(--gold);
    letter-spacing: 0.16em;
    text-transform: lowercase;
    margin: 0.2rem 0 1.4rem;
}

.loading-bar {
    width: min(18rem, 70vw);
    height: 4px;
    margin: 0.8rem auto;
    background: rgba(255, 255, 255, 0.1);
}

.loading-bar i {
    display: block;
    height: 100%;
    width: 0;
    background: var(--gold);
}

.pct {
    opacity: 0.6;
    font-size: 0.85rem;
}

.ember {
    display: block;
    width: 10px;
    height: 10px;
    margin: 0 auto 1rem;
    border-radius: 50%;
    background: var(--ember);
    box-shadow: 0 0 18px var(--ember);
    animation: glow 1.4s ease-in-out infinite;
}

@keyframes glow {
    50% { transform: scale(1.25); opacity: 0.7; }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    40% { opacity: 0.35; }
}

.end-overlay {
    background: #05060a;
}

@media (max-width: 720px) {
    .hud-top {
        flex-direction: column;
        padding-top: 4.6rem;
    }
    .line { font-size: 1.02rem; }
    .overlay-card { padding: 1.2rem 1.1rem; }
    .menu-head h1 { font-size: 1.45rem; }
}

@media (max-height: 520px) and (orientation: landscape) {
    .overlay-card {
        max-height: min(92dvh, 100%);
        padding: 0.9rem 1.1rem;
    }
    .menu-head h1 { font-size: 1.2rem; }
    .lede { margin-bottom: 0.8rem; }

    /* Deitado sobra largura e falta altura: os painéis voltam para uma linha. */
    .hud-top {
        flex-direction: row;
        padding-top: 3.6rem;
    }
    .line { font-size: 0.95rem; }
}

.keys-touch {
    display: none;
    margin: 0 0 1rem;
    font-size: 0.86rem;
    line-height: 1.5;
    color: #cdd5e4;
    opacity: 0.85;
}

@media (pointer: coarse) {
    .keys-touch {
        display: block;
    }
}

/* ---------------------------------------------------------------------------
   Controles de toque
   Só existem quando não há teclado nem pointer lock (ponteiro grosso). O stick
   fica à esquerda, os botões de ação à direita e o resto da tela é a câmera.
   --------------------------------------------------------------------------- */
.touch-controls {
    display: none;
}

@media (pointer: coarse) {
    .touch-controls {
        position: absolute;
        inset: 0;
        z-index: 14;
        display: block;
        pointer-events: none;
        touch-action: none;
        user-select: none;
        -webkit-user-select: none;
    }

    /* A camada de câmera cobre a tela inteira e fica atrás dos controles:
       arrastar em qualquer área livre gira a câmera. */
    .touch-look {
        position: absolute;
        inset: 0;
        pointer-events: auto;
        touch-action: none;
    }

    .touch-stick {
        position: absolute;
        left: calc(1.1rem + env(safe-area-inset-left, 0px));
        bottom: calc(1.4rem + env(safe-area-inset-bottom, 0px));
        width: 128px;
        height: 128px;
        border-radius: 50%;
        border: 1px solid rgba(255, 255, 255, 0.16);
        background: radial-gradient(circle at 50% 50%, rgba(12, 16, 26, 0.5), rgba(8, 10, 18, 0.28));
        backdrop-filter: blur(3px);
        pointer-events: auto;
        touch-action: none;
    }

    .touch-stick-knob {
        position: absolute;
        left: 50%;
        top: 50%;
        width: 54px;
        height: 54px;
        margin: -27px 0 0 -27px;
        border-radius: 50%;
        background: rgba(226, 200, 138, 0.32);
        border: 1px solid rgba(226, 200, 138, 0.55);
        box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
        transition: transform 0.08s ease-out;
    }

    .touch-stick.is-active .touch-stick-knob {
        transition: none;
        background: rgba(226, 200, 138, 0.5);
    }

    .touch-pad {
        position: absolute;
        right: calc(1rem + env(safe-area-inset-right, 0px));
        bottom: calc(1.4rem + env(safe-area-inset-bottom, 0px));
        display: grid;
        grid-template-columns: repeat(2, auto);
        gap: 10px;
        justify-items: end;
        pointer-events: none;
    }

    .touch-btn {
        pointer-events: auto;
        touch-action: none;
        width: 58px;
        height: 58px;
        border-radius: 50%;
        border: 1px solid rgba(255, 255, 255, 0.18);
        background: rgba(12, 16, 26, 0.5);
        backdrop-filter: blur(3px);
        color: #f4ead2;
        font-family: Outfit, system-ui, sans-serif;
        font-size: 1.25rem;
        line-height: 1;
        display: grid;
        place-items: center;
        cursor: pointer;
    }

    .touch-btn.is-active {
        background: rgba(226, 200, 138, 0.38);
        transform: scale(0.94);
    }

    .touch-btn-attack {
        background: rgba(120, 32, 32, 0.55);
        border-color: rgba(226, 138, 138, 0.4);
    }

    .touch-btn-jump {
        background: rgba(226, 200, 138, 0.22);
        border-color: rgba(226, 200, 138, 0.45);
    }

    .touch-side {
        position: absolute;
        right: calc(1rem + env(safe-area-inset-right, 0px));
        bottom: calc(9.6rem + env(safe-area-inset-bottom, 0px));
        display: flex;
        flex-direction: column;
        gap: 8px;
        align-items: flex-end;
        pointer-events: none;
    }

    .touch-chip {
        pointer-events: auto;
        touch-action: none;
        min-height: 34px;
        padding: 0 0.85rem;
        border-radius: 999px;
        border: 1px solid rgba(255, 255, 255, 0.16);
        background: rgba(12, 16, 26, 0.5);
        backdrop-filter: blur(3px);
        color: #cdd5e4;
        font-family: Outfit, system-ui, sans-serif;
        font-size: 0.78rem;
        letter-spacing: 0.06em;
        text-transform: uppercase;
        cursor: pointer;
    }

    .touch-chip[aria-pressed="true"] {
        background: rgba(226, 200, 138, 0.34);
        border-color: rgba(226, 200, 138, 0.55);
        color: #fff5e0;
    }

    /* O botão de pausa mora no canto superior direito: os painéis do HUD abrem
       espaço para ele em vez de passarem por baixo. */
    .hud-top {
        padding-right: 3.8rem;
    }

    .touch-pause {
        position: absolute;
        right: calc(1rem + env(safe-area-inset-right, 0px));
        top: calc(4.6rem + env(safe-area-inset-top, 0px));
        pointer-events: auto;
        touch-action: none;
        width: 44px;
        height: 44px;
        border-radius: 50%;
        border: 1px solid rgba(255, 255, 255, 0.16);
        background: rgba(12, 16, 26, 0.5);
        backdrop-filter: blur(3px);
        color: #cdd5e4;
        font-family: Outfit, system-ui, sans-serif;
        font-size: 0.9rem;
        letter-spacing: 0.1em;
        cursor: pointer;
    }

    /* Paisagem curta: encolhe o stick e os botões para não cobrirem a cena. */
    @media (max-height: 460px) {
        .touch-stick {
            width: 104px;
            height: 104px;
            bottom: calc(0.8rem + env(safe-area-inset-bottom, 0px));
        }

        .touch-stick-knob {
            width: 44px;
            height: 44px;
            margin: -22px 0 0 -22px;
        }

        .touch-btn {
            width: 50px;
            height: 50px;
            font-size: 1.05rem;
        }

        .touch-pad {
            bottom: calc(0.8rem + env(safe-area-inset-bottom, 0px));
        }

        .touch-side {
            bottom: calc(7.4rem + env(safe-area-inset-bottom, 0px));
        }
    }
}

/* agent-responsive-768 */
@media (max-width: 768px) {
  html, body { overflow-x: clip; }
  .hud, .overlay, .menu-overlay, .overlay-card {
    max-width: 100%;
  }
}
