/**
 * ==========================================================
 * WT Engine 0.5 Alpha
 * Responsive High-Density Canvas
 * ==========================================================
 */

:root {
    color-scheme: dark;
    --wt-visual-viewport-width: 100vw;
    --wt-visual-viewport-height: 100dvh;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    min-height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
    background: #202020;
    font-family: Arial, Helvetica, sans-serif;
}

body {
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding-top: env(safe-area-inset-top, 0px);
    padding-right: max(env(safe-area-inset-right, 0px), 4px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left: max(env(safe-area-inset-left, 0px), 4px);
}

#game-container {
    position: relative;
    flex: 0 0 auto;
    width: 720px;
    height: 1280px;
    max-width: 720px;
    max-height: 1280px;
    aspect-ratio: 9 / 16;
    background: #000;
    border-radius: clamp(0px, 1.4vw, 18px);
    overflow: hidden;
    box-shadow: 0 0 25px rgba(0, 0, 0, 0.6);
    contain: layout paint;
}

#gameCanvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    background: #111;
    image-rendering: auto;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    outline: none;
}

@media (max-width: 760px), (max-height: 1320px) {
    #game-container {
        border-radius: 0;
        box-shadow: none;
    }
}

/**
 * ==========================================================
 * Wild Tracer — Login Screen alinhada à imagem oficial
 * ==========================================================
 *
 * A arte final possui 941 × 1672 e é exibida em 720 × 1280.
 * Todos os controles abaixo usam coordenadas globais da tela,
 * evitando deslocamento causado por posição relativa do painel.
 */

.wt-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.wt-login-screen {
    position: absolute;
    inset: 0;
    z-index: 10000;
    overflow: hidden;
    isolation: isolate;
    opacity: 0;
    transition: opacity 240ms ease;
}

.wt-login-screen.is-ready {
    opacity: 1;
}

.wt-login-stage {
    --wt-login-scale: 1;
    position: absolute;
    left: 50%;
    top: 50%;
    width: 720px;
    height: 1280px;
    overflow: hidden;
    transform: translate(-50%, -50%) scale(var(--wt-login-scale));
    transform-origin: center center;
}

.wt-login-background {
    position: absolute;
    inset: 0;
    background: url('./assets/images/ui/login/login-background.webp') center center / cover no-repeat;
    pointer-events: none;
}

/* O formulário cobre toda a tela lógica. */
.wt-login-overlay {
    position: absolute;
    inset: 0;
    width: 720px;
    height: 1280px;
}

/* Seletor de idiomas alinhado aos botões desenhados na arte. */
.wt-login-language {
    position: absolute;
    left: 448.4px;
    top: 411.9px;
    width: 93.4px;
    height: 32.2px;
    display: grid;
    grid-template-columns: 1fr 1fr;
}

.wt-login-language-button {
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 3px;
    background: transparent;
    color: transparent;
    cursor: pointer;
    outline: none;
}

.wt-login-language-button.is-selected {
    box-shadow: inset 0 0 0 1px rgba(87, 211, 255, 0.22);
}

.wt-login-language-button:focus-visible,
.wt-login-hotspot:focus-visible,
.wt-login-input:focus-visible {
    outline: 2px solid rgba(97, 212, 255, 0.95);
    outline-offset: 1px;
}

/* Campos exatamente sobre os retângulos da imagem. */
.wt-login-hitbox {
    position: absolute;
    display: block;
}

.wt-login-hitbox--login {
    left: 275.4px;
    top: 575.7px;
    width: 249.6px;
    height: 48.2px;
}

.wt-login-hitbox--password {
    left: 275.4px;
    top: 646.9px;
    width: 249.6px;
    height: 48.2px;
}

.wt-login-input {
    display: block;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0 13px;
    border: 1px solid transparent;
    border-radius: 2px;
    outline: none;
    background: transparent;
    color: #e8f9ff;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 18px;
    font-weight: 700;
    line-height: 46px;
    letter-spacing: 0.01em;
    caret-color: #31c7ff;
    text-shadow: 0 0 7px rgba(0, 175, 255, 0.34);
    appearance: none;
    -webkit-appearance: none;
}

.wt-login-input::placeholder {
    color: transparent;
}

.wt-login-input:focus {
    border-color: rgba(112, 222, 255, 0.72);
    background: rgba(1, 33, 57, 0.12);
    box-shadow: 0 0 0 1px rgba(45, 177, 255, 0.22), 0 0 11px rgba(0, 175, 255, 0.18);
}

/* Áreas de clique alinhadas aos elementos visuais já desenhados. */
.wt-login-hotspot {
    position: absolute;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 5px;
    background: transparent;
    color: transparent;
    cursor: pointer;
}

.wt-login-hotspot:hover {
    box-shadow: inset 0 0 0 1px rgba(115, 222, 255, 0.16);
}

.wt-login-hotspot--register {
    left: 187px;
    top: 721px;
    width: 145px;
    height: 39px;
}

.wt-login-hotspot--recover {
    left: 395px;
    top: 721px;
    width: 145px;
    height: 39px;
}

.wt-login-hotspot--submit {
    left: 187.4px;
    top: 787px;
    width: 150px;
    height: 69.7px;
    border-radius: 8px;
}

.wt-login-hotspot--back {
    left: 381.1px;
    top: 787px;
    width: 150.8px;
    height: 69.7px;
    border-radius: 8px;
}

.wt-login-message {
    position: absolute;
    left: 190px;
    top: 872px;
    width: 340px;
    min-height: 42px;
    padding: 10px 14px;
    text-align: center;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.35;
    color: #dcefff;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 180ms ease, transform 180ms ease;
    background: rgba(0, 8, 18, 0.82);
    border: 1px solid rgba(61, 177, 255, 0.36);
    border-radius: 8px;
    box-shadow: 0 14px 24px rgba(0, 0, 0, 0.36);
}

.wt-login-message.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.wt-login-message[data-type='error'] {
    color: #ffe2e2;
    border-color: rgba(255, 72, 72, 0.45);
    background: rgba(36, 4, 8, 0.88);
}

/* Tradução visual usada apenas no modo EN. */
.wt-login-translation-layer {
    pointer-events: none;
    opacity: 0;
    transition: opacity 160ms ease;
}

.wt-login-screen[data-language='en'] .wt-login-translation-layer {
    opacity: 1;
}

.wt-login-translation {
    position: absolute;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-weight: 800;
}

.wt-login-translation--password {
    left: 190px;
    top: 642px;
    width: 76px;
    height: 57px;
    color: #d8d8d8;
    font-size: 11px;
    line-height: 1.05;
    text-shadow: 0 1px 2px #000;
    background: rgba(1, 12, 23, 0.97);
}

.wt-login-translation--register,
.wt-login-translation--recover {
    top: 718px;
    height: 43px;
    color: #27b8ff;
    font-size: 12px;
    background: rgba(1, 12, 23, 0.94);
    text-shadow: 0 0 8px rgba(0, 175, 255, 0.28);
}

.wt-login-translation--register {
    left: 215px;
    width: 112px;
}

.wt-login-translation--recover {
    left: 419px;
    width: 112px;
}

.wt-login-translation--submit,
.wt-login-translation--back {
    top: 793px;
    height: 57px;
    border-radius: 7px;
    color: #fff;
    font-size: 18px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.75);
}

.wt-login-translation--submit {
    left: 187.4px;
    width: 150px;
    background: linear-gradient(180deg, rgba(133, 207, 255, 0.96), rgba(18, 164, 237, 0.96));
}

.wt-login-translation--back {
    left: 381.1px;
    width: 150.8px;
    background: linear-gradient(180deg, rgba(252, 125, 125, 0.96), rgba(226, 27, 27, 0.96));
}

.wt-login-screen.is-busy .wt-login-hotspot,
.wt-login-screen.is-busy .wt-login-language-button,
.wt-login-screen.is-busy .wt-login-input {
    cursor: wait;
}

/* ==========================================================
 * Cadastro e recuperação — Etapas 22 e 23
 * ========================================================== */

.wt-account-dialog {
    position: absolute;
    inset: 0;
    z-index: 30;
    display: grid;
    place-items: center;
    padding: 56px;
    background: rgba(0, 5, 12, 0.82);
    backdrop-filter: blur(5px);
}

.wt-account-dialog[hidden] {
    display: none;
}

.wt-account-panel {
    width: 520px;
    max-height: 1080px;
    overflow-y: auto;
    padding: 34px;
    border: 1px solid rgba(89, 204, 255, 0.62);
    border-radius: 18px;
    background:
        linear-gradient(180deg, rgba(8, 29, 46, 0.98), rgba(2, 11, 22, 0.99));
    box-shadow:
        0 28px 80px rgba(0, 0, 0, 0.72),
        inset 0 0 0 1px rgba(255, 255, 255, 0.04);
    color: #eefaff;
}

.wt-account-title {
    margin: 0 0 26px;
    color: #54ceff;
    font: 800 27px/1.2 Arial, Helvetica, sans-serif;
    letter-spacing: 0.04em;
    text-align: center;
    text-shadow: 0 0 15px rgba(0, 173, 255, 0.28);
}

.wt-account-field {
    display: grid;
    gap: 8px;
    margin: 0 0 18px;
}

.wt-account-field[hidden],
.wt-account-reset-fields[hidden] {
    display: none;
}

.wt-account-field > span {
    color: #a9c8d7;
    font: 700 13px/1.2 Arial, Helvetica, sans-serif;
    letter-spacing: 0.06em;
}

.wt-account-field input {
    width: 100%;
    height: 52px;
    padding: 0 14px;
    border: 1px solid rgba(113, 181, 213, 0.48);
    border-radius: 7px;
    outline: none;
    background: rgba(1, 9, 18, 0.94);
    color: #f3fbff;
    font: 700 17px/1 Arial, Helvetica, sans-serif;
    caret-color: #3cc8ff;
}

.wt-account-field input:focus {
    border-color: rgba(76, 207, 255, 0.95);
    box-shadow: 0 0 0 2px rgba(44, 180, 255, 0.18);
}

.wt-account-message {
    min-height: 44px;
    margin: 4px 0 16px;
    padding: 10px 12px;
    border: 1px solid transparent;
    border-radius: 8px;
    color: #dcefff;
    font: 700 14px/1.35 Arial, Helvetica, sans-serif;
    text-align: center;
    opacity: 0;
}

.wt-account-message.is-visible {
    opacity: 1;
    border-color: rgba(61, 177, 255, 0.36);
    background: rgba(0, 8, 18, 0.72);
}

.wt-account-message[data-type='error'] {
    color: #ffe2e2;
    border-color: rgba(255, 72, 72, 0.48);
    background: rgba(36, 4, 8, 0.84);
}

.wt-account-actions {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 14px;
}

.wt-account-actions button {
    min-height: 54px;
    border: 0;
    border-radius: 9px;
    color: #ffffff;
    cursor: pointer;
    font: 800 15px/1.2 Arial, Helvetica, sans-serif;
    letter-spacing: 0.02em;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

.wt-account-primary {
    background: linear-gradient(180deg, #5ed6ff, #158ed1);
    box-shadow: 0 8px 22px rgba(0, 148, 220, 0.22);
}

.wt-account-secondary {
    background: linear-gradient(180deg, #e36767, #9c2424);
}

.wt-login-screen.is-busy .wt-account-actions button,
.wt-login-screen.is-busy .wt-account-field input {
    cursor: wait;
}


/* ==========================================================
 * Chat — compositor DOM sobre o canvas
 * ==========================================================
 *
 * O campo de mensagem precisa permanecer acima do canvas para
 * receber foco, teclado físico e teclado virtual. Sem posição e
 * camada próprias, o textarea fica atrás da renderização do jogo.
 */

.wt-chat-composer-input {
    position: absolute;
    z-index: 120;
    display: block;
    margin: 0;
    resize: none;
    overflow: hidden;
    border: 0;
    outline: none;
    background: transparent;
    color: #f3f7fa;
    font-family: Arial, Helvetica, sans-serif;
    font-weight: 600;
    caret-color: #5bb4df;
    opacity: 1;
    pointer-events: auto;
    touch-action: manipulation;
    user-select: text;
    -webkit-user-select: text;
    -webkit-appearance: none;
    appearance: none;
}

.wt-chat-composer-input::placeholder {
    color: rgba(154, 168, 178, 0.82);
}

.wt-chat-composer-input:focus {
    background: rgba(6, 13, 20, 0.2);
    box-shadow: inset 0 0 0 1px rgba(91, 180, 223, 0.32);
}

.wt-chat-composer-input:disabled {
    pointer-events: none;
    color: rgba(154, 168, 178, 0.62);
    -webkit-text-fill-color: rgba(154, 168, 178, 0.62);
    opacity: 0.72;
}

/* ==========================================================
 * Etapas 38 e 39 — compatibilidade visual e testes controlados
 * ========================================================== */

html,
body {
    min-width: 100%;
    min-height: var(--wt-visual-viewport-height, 100dvh);
}

#game-container {
    max-width: var(--wt-visual-viewport-width, 100vw);
    max-height: var(--wt-visual-viewport-height, 100dvh);
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
