/* ============ Identidade de jogo de palavras ============ */
/* Camada carregada por último: troca as peças escuras por peças de letra cor de
   marfim com tinta escura, e repete esse mesmo motivo onde o jogo mostra uma
   palavra (palavra em formação, palavra-alvo, histórico, avatar). Remover o
   import em main.js desfaz tudo. */

:root {
    --wb-tile-face: #f6ecd6;
    --wb-tile-face-hi: #fffaf0;
    --wb-tile-edge: #c9b48a;
    --wb-tile-ink: #18233f;
}

/* Cores lidas pelo canvas do tabuleiro (refreshThemeColors em gameEngine.js) */
body,
body.theme-dark,
body.wb-mobile-ui,
body.wb-mobile-ui.theme-dark {
    --tile-normal: #f6ecd6;
    --tile-selected: #7cc8ff;
    --tile-bonus: #ffd866;
    --tile-bomb: #ff9d94;
    --tile-time: #8fe3ae;
    --tile-text: #18233f;
}

/* Pecinha de letra usada fora do canvas */
.wb-letter-tile {
    display: inline-block;
    box-sizing: border-box;
    min-width: 1.5em;
    height: 1.62em;
    margin: 0 2px 3px 0;
    padding: 0 0.22em;
    border-radius: 0.34em;
    background: linear-gradient(180deg, var(--wb-tile-face-hi) 0%, var(--wb-tile-face) 100%);
    box-shadow:
        0 3px 0 var(--wb-tile-edge),
        inset 0 1px 0 rgba(255, 255, 255, 0.7);
    color: var(--wb-tile-ink);
    font-weight: 900;
    line-height: 1.62em;
    letter-spacing: 0;
    text-align: center;
    text-transform: uppercase;
    vertical-align: middle;
}

/* Palavra em formação: as letras entram como peças na "estante" */
body.wb-board-active .current-word-main {
    letter-spacing: 0;
    overflow: hidden;
    font-size: 1.15rem !important;
    min-height: 2.1em;
    line-height: 2.1em;
}

body.wb-board-active #current-word .wb-letter-tile {
    animation: wb-tile-drop 0.14s ease-out;
}

@keyframes wb-tile-drop {
    from {
        transform: translateY(-6px) scale(0.86);
        opacity: 0.4;
    }
    to {
        transform: none;
        opacity: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    body.wb-board-active #current-word .wb-letter-tile {
        animation: none;
    }
}

/* Palavra-alvo no HUD: peças menores, tom dourado para marcar o bônus */
.hud-target-word,
body.wb-mobile-ui .hud-target-word {
    letter-spacing: 0;
    font-size: 0.8rem;
    line-height: 1.9;
}

.hud-target-word .wb-letter-tile {
    background: linear-gradient(180deg, #fff3c4 0%, #ffd866 100%);
    box-shadow:
        0 2px 0 #b98a1c,
        inset 0 1px 0 rgba(255, 255, 255, 0.7);
    margin-bottom: 2px;
}

/* Tabuleiro: bandeja escura para as peças claras assentarem */
body.wb-mobile-ui #game-container {
    background: linear-gradient(180deg, #0c1a3a 0%, #060e24 100%);
    border: 1px solid rgba(246, 236, 214, 0.22);
    box-shadow:
        0 24px 40px -28px rgba(0, 0, 0, 0.9),
        inset 0 0 0 3px rgba(6, 12, 30, 0.55);
}

#gameCanvas {
    background: linear-gradient(180deg, #071029 0%, #0a1634 100%);
}

/* Histórico: cada palavra achada vira uma ficha de marfim */
body.wb-board-active .history-pill {
    background: linear-gradient(180deg, var(--wb-tile-face-hi) 0%, var(--wb-tile-face) 100%);
    border: 0;
    border-radius: 10px;
    box-shadow: 0 3px 0 var(--wb-tile-edge);
    color: var(--wb-tile-ink);
}

body.wb-board-active .history-pill .word-text {
    color: var(--wb-tile-ink);
    font-weight: 900;
    letter-spacing: 0.06em;
}

body.wb-board-active .history-pill .points {
    color: #0f7a45;
}

/* Home: a inicial do jogador é uma peça de letra */
body.wb-mobile-ui #start-screen .hp-avatar-initial {
    background: linear-gradient(180deg, var(--wb-tile-face-hi) 0%, var(--wb-tile-face) 100%);
    border: 0;
    box-shadow:
        0 4px 0 var(--wb-tile-edge),
        inset 0 1px 0 rgba(255, 255, 255, 0.7);
    color: var(--wb-tile-ink);
    font-weight: 900;
}

/* Home: os ícones dos modos ganham a espessura de uma peça, na cor do modo */
.hm-icon {
    box-shadow:
        0 3px 0 color-mix(in srgb, var(--hm-accent) 58%, #000000),
        inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

/* Piso de leitura nos cards de modo: nada abaixo de 12 px */
.hm-tag {
    font-size: 0.75rem;
}

.hm-desc {
    font-size: 0.8125rem;
    line-height: 1.35;
}

.hm-meta {
    font-size: 0.75rem;
}

/* ============ O mesmo motivo nas outras telas ============ */

/* Ranking: a posição de cada jogador é uma peça numerada */
#rank-screen .rk-pos,
#rank-screen .rk-row--me .rk-pos {
    display: inline-grid;
    place-items: center;
    min-width: 30px;
    height: 30px;
    padding: 0 6px;
    border-radius: 9px;
    background: linear-gradient(180deg, var(--wb-tile-face-hi) 0%, var(--wb-tile-face) 100%);
    box-shadow:
        0 3px 0 var(--wb-tile-edge),
        inset 0 1px 0 rgba(255, 255, 255, 0.7);
    color: var(--wb-tile-ink);
    font-weight: 900;
}

/* Pré-partida: os contadores de power-up têm a espessura das peças do tabuleiro */
body .pre-match-counter-square {
    border-radius: 12px;
    box-shadow:
        0 4px 0 rgba(0, 0, 0, 0.32),
        inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

body .pre-match-counter-value {
    color: var(--wb-tile-ink);
    font-weight: 900;
}

/* Loja e aviso de energia: o ícone principal também é uma peça */
body .er-bolt {
    box-shadow:
        0 4px 0 #b9741c,
        inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

/* Resultado: a melhor palavra aparece como ficha de marfim */
body .pg-stat-word strong {
    display: inline-block;
    padding: 3px 10px 2px;
    border-radius: 8px;
    background: linear-gradient(180deg, var(--wb-tile-face-hi) 0%, var(--wb-tile-face) 100%);
    box-shadow: 0 3px 0 var(--wb-tile-edge);
    color: var(--wb-tile-ink);
    letter-spacing: 0.08em;
}

/* Stats: as palavras mais usadas são fichas, com a contagem em tinta escura */
body .word-tag {
    padding: 6px 8px 5px 12px;
    border: 0;
    border-radius: 10px;
    background: linear-gradient(180deg, var(--wb-tile-face-hi) 0%, var(--wb-tile-face) 100%);
    box-shadow: 0 3px 0 var(--wb-tile-edge);
    color: var(--wb-tile-ink);
    font-weight: 900;
    letter-spacing: 0.06em;
    backdrop-filter: none;
}

body .word-tag:hover {
    background: var(--wb-tile-face-hi);
}

body .word-tag .count {
    background: var(--wb-tile-ink);
    color: var(--wb-tile-face-hi);
    letter-spacing: 0;
}
