/* Claude Bros — layout do jogo.
   O shell compartilhado (labs/shared.css) entrega header, footer, tema e os
   tokens de safe-area; aqui só entra o que é do jogo. */

body {
    /* Fullscreen: o palco ocupa a altura livre e a página não rola.
       O fundo continua sendo o token do tema — o azul é do céu da fase, dentro
       do palco, não da página (senão o header claro fica ilegível). */
    padding: 0;
    overflow: hidden;
}

.game-shell {
    width: 100%;
    max-width: 1200px;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: max(0.75rem, var(--safe-top))
        max(0.75rem, var(--safe-right))
        max(0.5rem, var(--safe-bottom))
        max(0.75rem, var(--safe-left));
    margin: 0 auto;
}

[data-lab-header] {
    margin-bottom: 0;
    padding: 0;
    flex: 0 0 auto;
}

/* O palco toma a altura que sobra; `min-height: 0` é o que permite ao flex
   encolhê-lo em telas baixas em vez de estourar a página. */
.stage {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    border-radius: 1rem;
    overflow: hidden;
    background: #5aa9e6;
    box-shadow: 0 18px 48px rgba(4, 20, 34, 0.45);
    /* Os gestos do jogo não podem virar scroll/zoom da página. */
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.stage canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* ------------------------------------------------------------------- HUD --- */

.hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.6rem;
    pointer-events: none;
}

.hud-chip {
    display: inline-flex;
    align-items: baseline;
    gap: 0.35rem;
    padding: 0.3rem 0.6rem;
    border-radius: 999px;
    background: rgba(8, 26, 42, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    color: #fff;
    font-size: 0.8rem;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.hud-key {
    font-size: 0.62rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.72;
}

.hud-chip strong {
    font-weight: 700;
}

/* --------------------------------------------------------------- overlay --- */

.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(6, 20, 34, 0.55);
    /* Blur leve: o menu precisa se destacar sem apagar a fase atrás dele. */
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 20;
}

.overlay[hidden] {
    display: none;
}

.overlay-card {
    /* Menu longo em tela baixa rola dentro do card, sem empurrar o jogo. */
    max-width: min(30rem, 100%);
    max-height: min(92dvh, 100%);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.85rem;
    padding: clamp(1.25rem, 4vw, 2rem);
    text-align: center;
    border-radius: 1.25rem;
    background: rgba(12, 30, 48, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #f2f7fb;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.overlay-card h2 {
    font-size: clamp(1.5rem, 6vw, 2.25rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #ffb894;
}

.overlay-card p {
    font-size: clamp(0.9rem, 3.2vw, 1rem);
    line-height: 1.5;
    color: rgba(242, 247, 251, 0.82);
}

.overlay-hint {
    font-size: 0.8rem !important;
    opacity: 0.65;
}

.primary-btn {
    min-height: var(--touch-target);
    padding: 0.75rem 2rem;
    border: 0;
    border-radius: 999px;
    background: #d97757;
    color: #fff;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, filter 0.2s ease;
}

.primary-btn:hover {
    filter: brightness(1.08);
    transform: translateY(-2px);
}

.primary-btn:active {
    transform: translateY(0) scale(0.97);
}

.primary-btn:focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 3px;
}

/* ------------------------------------------------------ controles de toque --- */

.touch-controls {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    /* Default oculto: só aparece com pointer:coarse (evita pads em VMs/desktop híbrido). */
    display: none;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    /* Os controles sobem acima do home indicator. */
    padding: 0 max(0.9rem, var(--safe-left)) max(0.9rem, var(--safe-bottom))
        max(0.9rem, var(--safe-right));
    z-index: 15;
}

.touch-controls[hidden] {
    display: none !important;
}

.touch-move {
    display: flex;
    gap: 0.75rem;
}

.touch-btn {
    /* 60px: acima do mínimo de 44px, porque aqui o dedo fica apoiado. */
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.35);
    background: rgba(10, 28, 45, 0.42);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    color: #fff;
    font-size: 1.4rem;
    font-family: inherit;
    cursor: pointer;
    touch-action: none;
    transition: background 0.12s ease, transform 0.12s ease;
}

.touch-btn.is-active,
.touch-btn:active {
    background: rgba(217, 119, 87, 0.75);
    transform: scale(0.94);
}

.touch-btn--jump {
    width: 74px;
    height: 74px;
    font-size: 1.6rem;
    background: rgba(217, 119, 87, 0.42);
}

.touch-btn:focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 3px;
}

/* --------------------------------------------------------------- responsivo --- */

@media (max-width: 768px) {
    .game-shell {
        gap: 0.5rem;
    }

    .hud {
        padding: 0.45rem;
        gap: 0.3rem;
    }

    .hud-chip {
        padding: 0.25rem 0.5rem;
        font-size: 0.72rem;
    }
}

/* Landscape curto: o header encolhe (shared.css já cuida) e os controles
   ficam mais baixos e menores para não cobrir o chão da fase. */
@media (max-height: 520px) and (orientation: landscape) {
    .game-shell {
        gap: 0.4rem;
        padding-bottom: max(0.25rem, var(--safe-bottom));
    }

    [data-lab-footer] {
        display: none;
    }

    .touch-btn {
        width: 52px;
        height: 52px;
        font-size: 1.2rem;
    }

    .touch-btn--jump {
        width: 62px;
        height: 62px;
        font-size: 1.35rem;
    }

    .hud {
        padding: 0.35rem 0.5rem;
    }
}

/* Com mouse/teclado os botões de toque só atrapalham a vista. */
@media (pointer: fine) {
    .touch-controls {
        display: none !important;
    }
}

@media (pointer: coarse) {
    .touch-controls:not([hidden]) {
        display: flex;
    }
}
