/* Pré-partida curta da camada de jogo: título, seis peças em ícones, custo, JOGAR e Voltar.
   O modal antigo (#pre-match-loadout-modal) segue no DOM e o uiModals.js continua mandando nele;
   aqui só se esconde o que excede e se refaz o layout. Tudo atrás de .wb-game-ui. */

/* Ícones novos: sem a classe da camada nem existem para o resto do site. */
.gm-pm-ic,
.gm-pm-lock {
    display: none;
}

/* O alvo do seletor é o ID do modal: vence as regras antigas (main.css/ui.css) sem !important,
   menos onde o HTML traz estilo inline (min-height e max-width do contêiner e do cartão). */
html.wb-game-ui body #pre-match-loadout-modal {
    --pm-face: clamp(48px, 15dvh, 92px);
    background: var(--gm-stage);
    background-attachment: fixed;
    overflow: hidden;
    font-family: var(--gm-font-label);
    color: var(--gm-text);
}

html.wb-game-ui body #pre-match-loadout-modal > .container {
    min-height: 0 !important;
    flex: none;
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    max-width: none;
    padding: max(10px, env(safe-area-inset-top)) 10px max(10px, var(--wb-safe-bottom));
}

html.wb-game-ui body #pre-match-loadout-modal .pre-match-loadout-card {
    position: relative;
    overflow: visible;
    width: min(100%, 680px) !important;
    max-width: 680px !important;
    max-height: none !important;
    padding: clamp(12px, 2.4dvh, 22px) clamp(10px, 2.4vw, 22px) !important;
    background: var(--gm-panel);
    color: var(--gm-text);
    border: var(--gm-border) solid var(--gm-outline);
    border-radius: var(--gm-radius);
    box-shadow: var(--gm-shadow);
    backdrop-filter: none;
    display: flex;
    flex-direction: column;
    gap: clamp(8px, 1.6dvh, 14px);
}

/* Nada do cartão encolhe: se faltar altura, o teste acusa em vez de sobrepor */
html.wb-game-ui body #pre-match-loadout-modal .pre-match-loadout-card > * {
    flex: none;
}

/* bottom-nav.css acrescenta 80px + banner ao fim de todo .screen quando há banner; aqui a
   reserva é feita só no contêiner (abaixo) */
html.wb-game-ui body #pre-match-loadout-modal.screen {
    padding: 0;
}

html.wb-game-ui body.wb-banner-visible #pre-match-loadout-modal > .container {
    padding-bottom: calc(var(--wb-banner-height, 60px) + 6px);
}

/* Faixa de divulgação do site (web) fica por cima do modal: reserva o espaço dela */
html.wb-game-ui body:has(#wb-house-banner.is-visible) #pre-match-loadout-modal > .container {
    padding-bottom: 66px;
}

@media (min-width: 768px) {
    html.wb-game-ui body:has(#wb-house-banner.is-visible) #pre-match-loadout-modal > .container {
        padding-bottom: 96px;
    }
}

/* ---- O que sai: logo, chamada, subtítulo, "Como jogar", abas, resumo e a oferta VIP ---- */
html.wb-game-ui body #pre-match-loadout-modal .pm-v2 .pre-match-brand-logo,
html.wb-game-ui body #pre-match-loadout-modal .pm-v2 .pre-match-kicker,
html.wb-game-ui body #pre-match-loadout-modal .pm-v2 .pre-match-subtitle,
html.wb-game-ui body #pre-match-loadout-modal .pm-v2 .pm-how-to,
html.wb-game-ui body #pre-match-loadout-modal .pm-v2 .pre-match-tabs,
html.wb-game-ui body #pre-match-loadout-modal .pm-v2 #pre-match-pane-summary,
html.wb-game-ui body #pre-match-loadout-modal .pm-v2 #pre-match-vip-lock,
html.wb-game-ui body #pre-match-loadout-modal .pm-v2 .pre-match-powerup-copy p,
html.wb-game-ui body #pre-match-loadout-modal .pm-v2 .pre-match-powerup-meta {
    display: none !important;
}

/* Modo e duração logo abaixo do título (texto preenchido pelo uiModals.js) */
.pre-match-meta {
    display: none;
}

html.wb-game-ui body #pre-match-loadout-modal .pm-v2 .pre-match-meta {
    display: block;
    margin: 2px 0 0;
    color: var(--gm-text);
    font-family: var(--gm-font-label);
    font-weight: 700;
    font-size: clamp(0.85rem, 2.3dvh, 1rem);
    line-height: 1.2;
}

html.wb-game-ui body #pre-match-loadout-modal .pm-v2 .pre-match-meta:empty {
    display: none;
}

/* ---- Título ---- */
html.wb-game-ui body #pre-match-loadout-modal .pm-v2 .pre-match-head {
    margin: 0 !important;
    padding: 0 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center !important;
}

html.wb-game-ui body #pre-match-loadout-modal .pm-v2 .pre-match-combo-panel {
    margin: 0;
    padding: 0;
    background: none;
    border: 0;
    box-shadow: none;
}

html.wb-game-ui body #pre-match-loadout-modal .pm-v2 #pre-match-title {
    margin: 0 !important;
    color: var(--gm-accent);
    font-family: var(--gm-font);
    font-weight: 400;
    font-size: clamp(1.4rem, 4.2dvh, 2rem);
    line-height: 1.1;
}

/* ---- Fechar (a seta Voltar já faz o mesmo; fica como atalho no canto) ---- */
html.wb-game-ui body #pre-match-loadout-modal .pm-v2 .btn-close {
    top: 6px;
    right: 6px;
    width: 44px;
    height: 44px;
    background-color: var(--gm-outline);
    border: 1.5px solid var(--gm-outline);
}

/* ---- Grade das seis peças: 6x1 na paisagem, 3x2 no retrato ---- */
html.wb-game-ui body #pre-match-loadout-modal .pm-v2 #pre-match-pane-combo {
    flex: none;
    display: block;
    padding: 0;
    margin: 0;
    overflow: visible;
}

html.wb-game-ui body #pre-match-loadout-modal .pm-v2 #pre-match-pane-combo.hidden {
    display: none;
}

html.wb-game-ui body #pre-match-loadout-modal .pm-v2 .pre-match-powerup-list {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 8px;
    margin: 0;
    padding: 0;
    max-height: none;
    overflow: visible;
}

@media (orientation: portrait) {
    html.wb-game-ui body #pre-match-loadout-modal {
        --pm-face: clamp(48px, 10dvh, 92px);
    }

    html.wb-game-ui body #pre-match-loadout-modal .pm-v2 .pre-match-powerup-list {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        row-gap: clamp(8px, 1.6dvh, 14px);
    }
}

html.wb-game-ui body #pre-match-loadout-modal .pm-v2 .pre-match-powerup-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    min-width: 0;
    padding: 0;
    margin: 0;
    background: none;
    border: 0;
    box-shadow: none;
    border-radius: 0;
}

/* A face colorida da peça: o quadrado do contador vira o botão-ícone */
html.wb-game-ui body #pre-match-loadout-modal .pm-v2 .pre-match-counter-square {
    --pm-c: #8f5cf0;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--pm-face);
    height: var(--pm-face);
    min-width: 0;
    margin: 0;
    padding: 0;
    background: linear-gradient(rgba(255, 255, 255, 0.32), rgba(255, 255, 255, 0) 60%), var(--pm-c);
    border: var(--gm-border) solid var(--gm-outline);
    border-radius: var(--gm-radius);
    box-shadow: var(--gm-shadow);
}

html.wb-game-ui body #pre-match-loadout-modal .pm-v2 .pre-match-counter-square-red { --pm-c: #ef4a6d; }
html.wb-game-ui body #pre-match-loadout-modal .pm-v2 .pre-match-counter-square-yellow { --pm-c: #f5b82e; }
html.wb-game-ui body #pre-match-loadout-modal .pm-v2 .pre-match-counter-square-green { --pm-c: #3ccf6e; }
html.wb-game-ui body #pre-match-loadout-modal .pm-v2 .pre-match-counter-square-blue { --pm-c: #3aa0ff; }
html.wb-game-ui body #pre-match-loadout-modal .pm-v2 .pre-match-counter-square-orange { --pm-c: #8f5cf0; }
html.wb-game-ui body #pre-match-loadout-modal .pm-v2 .pre-match-counter-square-ice { --pm-c: #52d0e8; }

html.wb-game-ui body #pre-match-loadout-modal .pm-v2 .gm-pm-ic {
    display: block;
    width: 62%;
    height: 62%;
}

/* Quantidade: selo dourado no canto da peça */
html.wb-game-ui body #pre-match-loadout-modal .pm-v2 .pre-match-counter-value {
    position: absolute;
    top: -8px;
    right: -8px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    height: 26px;
    padding: 0 6px;
    background: var(--gm-accent);
    color: var(--gm-text-dark);
    border: 1.5px solid var(--gm-outline);
    border-radius: 999px;
    font-family: var(--gm-font);
    font-size: 0.95rem;
    line-height: 1;
}

/* Cadeado: peça que o jogador não pode montar (mesma regra do modal: sem VIP e sem unidade
   ganha, ou seja, painel .is-locked e linha sem .is-selected). */
html.wb-game-ui body #pre-match-loadout-modal .pm-v2 .gm-pm-lock {
    display: none;
    position: absolute;
    right: -6px;
    bottom: -6px;
    width: 34%;
    height: 34%;
    padding: 3px;
    box-sizing: border-box;
    background: var(--gm-outline);
    border-radius: 50%;
}

html.wb-game-ui body #pre-match-loadout-modal .pm-v2 #pre-match-pane-combo.is-locked .pre-match-powerup-row:not(.is-selected) .gm-pm-lock {
    display: block;
}

html.wb-game-ui body #pre-match-loadout-modal .pm-v2 #pre-match-pane-combo.is-locked .pre-match-powerup-row:not(.is-selected) .pre-match-counter-square {
    filter: saturate(0.5) brightness(0.9);
}

html.wb-game-ui body #pre-match-loadout-modal .pm-v2 #pre-match-pane-combo.is-locked .pre-match-powerup-row:not(.is-selected) {
    opacity: 1;
}

/* Nome da peça */
html.wb-game-ui body #pre-match-loadout-modal .pm-v2 .pre-match-powerup-copy {
    order: 2;
    width: 100%;
    margin: 0;
    padding: 0;
    text-align: center;
}

html.wb-game-ui body #pre-match-loadout-modal .pm-v2 .pre-match-powerup-copy strong {
    display: block;
    color: var(--gm-text);
    font-family: var(--gm-font);
    font-weight: 400;
    font-size: clamp(0.78rem, 2.2dvh, 0.95rem);
    line-height: 1.15;
}

/* Mais e menos: só para quem pode montar (VIP). Sem VIP os botões já vêm desabilitados
   pelo uiModals.js; esconder poupa a altura e não promete o que não dá. */
html.wb-game-ui body #pre-match-loadout-modal .pm-v2 .pre-match-stepper {
    order: 3;
    display: flex;
    gap: 4px;
    width: 100%;
    margin: 0;
    padding: 0;
    justify-content: center;
}

html.wb-game-ui body #pre-match-loadout-modal .pm-v2 #pre-match-pane-combo.is-locked .pre-match-stepper {
    display: none;
}

html.wb-game-ui body #pre-match-loadout-modal .pm-v2 .pre-match-stepper button {
    flex: 1 1 0;
    min-width: 44px;
    max-width: 52px;
    height: 44px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--gm-blue);
    color: var(--gm-text-dark);
    border: 1.5px solid var(--gm-outline);
    border-radius: 14px;
    box-shadow: none;
    font-size: 1.1rem;
}

html.wb-game-ui body #pre-match-loadout-modal .pm-v2 .pre-match-stepper button:disabled {
    opacity: 0.4;
    box-shadow: none;
}

html.wb-game-ui body #pre-match-loadout-modal .pm-v2 .pre-match-stepper button:focus-visible,
html.wb-game-ui body #pre-match-loadout-modal .pm-v2 .pre-match-footer-actions .btn:focus-visible,
html.wb-game-ui body #pre-match-loadout-modal .pm-v2 .btn-close:focus-visible {
    outline: 3px solid var(--gm-accent);
    outline-offset: 2px;
}

/* ---- Conta da energia ---- */
html.wb-game-ui body #pre-match-loadout-modal .pm-v2 .pm-cost-line {
    margin: 0;
    padding: 0;
    text-align: center;
    color: var(--gm-text);
    background: none;
    border: 0;
    font-size: clamp(0.9rem, 2.4dvh, 1.05rem);
    line-height: 1.2;
}

html.wb-game-ui body #pre-match-loadout-modal .pm-v2 .pm-cost-warn {
    color: var(--gm-accent);
}

/* ---- JOGAR e Voltar ---- */
html.wb-game-ui body #pre-match-loadout-modal .pm-v2 .pre-match-footer-bar {
    margin: 0 !important;
}

html.wb-game-ui body #pre-match-loadout-modal .pm-v2 .pre-match-footer-actions {
    display: flex !important;
    flex-direction: column;
    gap: 8px !important;
}

html.wb-game-ui body #pre-match-loadout-modal .pm-v2 .pre-match-footer-actions .btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 48px;
    margin: 0;
    padding: 6px 20px;
    color: var(--gm-text-dark);
    border: var(--gm-border) solid var(--gm-outline);
    border-radius: var(--gm-radius);
    box-shadow: var(--gm-shadow);
    font-family: var(--gm-font);
    font-weight: 400;
    font-size: 1.2rem;
    letter-spacing: 0.02em;
    text-shadow: none;
    transition: transform 0.08s ease, box-shadow 0.08s ease;
}

html.wb-game-ui body #pre-match-loadout-modal .pm-v2 .pre-match-play-btn {
    min-height: 54px;
    font-size: 1.4rem;
    background: var(--gm-green);
}

html.wb-game-ui body #pre-match-loadout-modal .pm-v2 .pre-match-play-btn.is-blocked {
    background: var(--gm-pink);
}

html.wb-game-ui body #pre-match-loadout-modal .pm-v2 .pre-match-skip-btn {
    background: var(--gm-blue);
}

html.wb-game-ui body #pre-match-loadout-modal .pm-v2 .pre-match-footer-actions .btn:active {
    transform: translateY(3px);
    box-shadow: none;
}

@media (prefers-reduced-motion: reduce) {
    html.wb-game-ui body #pre-match-loadout-modal .pm-v2 .pre-match-footer-actions .btn {
        transition: none;
    }
}

/* Economia de XP: preço de cada power-up e atalho para ganhar XP */
#pre-match-loadout-modal .pm-xp-price {
    display: inline-block;
    margin-top: 2px;
    padding: 1px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

#pre-match-loadout-modal .pm-xp-price[hidden] {
    display: none;
}

#pre-match-loadout-modal .pm-earn-xp {
    margin-left: 6px;
    padding: 2px 10px;
    border: 1.5px solid currentColor;
    border-radius: 999px;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}
