@import url('https://fonts.googleapis.com/css2?family=VT323&display=swap');

/* ===============================
   VARIÁVEIS GLOBAIS
================================ */
:root {
    --terminal-green: #33ff00;
    --terminal-dim: #1a8000;
    --bg-color: #050505;
}

/* ===============================
   RESET / BASE
================================ */
*,
*::before,
*::after {
    box-sizing: border-box;
}

:focus {
    outline: 2px solid #0f0;
}

body {
    margin: 0;
    background-color: var(--bg-color);
    color: var(--terminal-green);
    font-family: 'VT323', monospace;
    overflow: hidden;
}

/* =========================================
   FORÇA A OCULTAÇÃO DA HUD MOBILE NO DESKTOP
========================================= */
@media (hover: hover) and (pointer: fine) {

    #mobile-pause-btn,
    #mobile-fullscreen-btn,
    #mobile-settings-btn,
    #mobile-cafe-btn {
        display: none !important;
    }
}

/* ===============================
   ANIMAÇÕES
================================ */
@keyframes crtPulse {
    0% {
        filter: brightness(1);
    }

    50% {
        filter: brightness(1.2);
    }

    100% {
        filter: brightness(1);
    }
}

@keyframes arcadePulse {
    0% {
        box-shadow: 0 0 4px #ff0, inset 0 0 2px #ff0;
        filter: brightness(1);
    }

    50% {
        box-shadow:
            0 0 10px #ff0,
            0 0 18px rgba(255, 255, 0, .6),
            inset 0 0 4px #ff0;
        filter: brightness(1.3);
    }

    100% {
        box-shadow: 0 0 4px #ff0, inset 0 0 2px #ff0;
        filter: brightness(1);
    }
}

@keyframes legendPulse {
    0% {
        opacity: .6;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: .6;
    }
}

@keyframes scaleIn {
    from {
        transform: scale(.85);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes blinkCursor {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }

    100% {
        opacity: 1;
    }
}

@keyframes screenShake {
    0% {
        transform: translate(0);
    }

    20% {
        transform: translate(-5px, 5px);
    }

    40% {
        transform: translate(5px, -5px);
    }

    60% {
        transform: translate(-5px, -5px);
    }

    80% {
        transform: translate(5px, 5px);
    }

    100% {
        transform: translate(0);
    }
}

.shake {
    animation: screenShake 0.3s ease;
}

/* ===============================
   CRT OVERLAY
================================ */
.crt-overlay {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 10;
    background:
        linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, .25) 50%),
        linear-gradient(90deg,
            rgba(255, 0, 0, .06),
            rgba(0, 255, 0, .02),
            rgba(0, 0, 255, .06));
    background-size: 100% 2px, 3px 100%;
}

.dos-cursor {
    width: 10px;
    height: 14px;
    background: var(--terminal-green);
    animation: blinkCursor 1s steps(2) infinite;
}

.dos-popup {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    font-family: 'VT323', monospace;
}

.dos-popup.hidden {
    display: none;
}

.dos-window {
    background: #000;
    border: 3px solid #0f0;
    padding: 20px;
    color: #0f0;
    text-align: center;
    min-width: 300px;
    box-shadow: 0 0 20px #0f0;
}

.dos-window button {
    margin-top: 15px;
    background: black;
    color: #0f0;
    border: 2px solid #0f0;
    padding: 5px 15px;
    cursor: pointer;
}

.dos-window button:hover {
    background: #0f0;
    color: black;
}


/* ===============================
   TELA DE JOGO / CANVAS
================================ */
.canvas-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

#gameCanvas {
    width: 80vw;
    height: 80vh;
    max-width: 100%;
    max-height: 100%;
    image-rendering: pixelated;
    border: 2px solid var(--terminal-green);
    box-shadow: 0 0 25px var(--terminal-green);
}

.game-header {
    width: 100%;
    text-align: right;
    padding: 10px 20px;
}

/* ===============================
   SETTINGS / INPUT CONTAINER
================================ */
#settings-panel {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .92);
    padding: 32px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-y: auto;
}

.settings-group {
    background-color: rgba(255, 255, 255, 0.288);
}

.settings-group h3,
.settings-group2 h3 {
    text-align: center;
}

.hidden {
    display: none !important;
}

.hidden-exit {
    display: none !important;
}

.btn-exit {
    background: transparent;
    border: 1px solid var(--terminal-green);
    color: var(--terminal-green);
    font-family: 'VT323', monospace;
    padding: 10px;
    cursor: pointer;
    position: absolute;
    top: 20px;
    left: 20px;
}

.btn-exit:hover {
    color: #fff200;
    background-color: #aa0000;
    /* Vermelho para indicar saída/perigo */
    box-shadow: 0 0 10px rgba(170, 0, 0, 0.5);
}

/* =========================================
   BOTÃO DE RECORDES (HIGH SCORES)
========================================= */
.btn-ranking {
    background-color: #111111;
    color: #ffcc00;
    /* Dourado Arcade */
    border: 2px solid #ffcc00;
    padding: 10px 24px;
    font-family: 'VT323', monospace;
    font-size: 24px;
    letter-spacing: 2px;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(255, 204, 0, 0.2), inset 0 0 5px rgba(255, 204, 0, 0.1);
    transition: all 0.2s ease-in-out;
    text-shadow: 0 0 5px rgba(255, 204, 0, 0.5);
    border-radius: 4px;
    width: 100%;
}

.btn-ranking:hover {
    background-color: #ffcc00;
    color: #000000;
    box-shadow: 0 0 20px rgba(255, 204, 0, 0.8);
    text-shadow: none;
    transform: scale(1.05);
    /* Dá um pequeno pulo para frente */
}

.btn-ranking:active {
    transform: scale(0.95);
    /* Afunda quando clica */
    box-shadow: 0 0 10px rgba(255, 204, 0, 0.4);
}

/* ===============================
   TELA DE SELEÇÃO DE JOGO
================================ */
.game-grid {
    display: flex;
    flex-direction: row;
    justify-content: center;
    flex-wrap: wrap;
    /* Permite quebrar a linha apenas se a tela ficar muito apertada */
    gap: 20px;
    width: 100%;
    max-width: 1200px;
    margin: 40px auto 0 auto;
    padding: 0 20px;
}

.game-card {
    border: 2px solid var(--terminal-dim);
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;

    /* SUBSTITUA width: 150px; POR ISSO: */
    width: 100%;
    max-width: 180px;
    /* Impede que o card fique largo demais no desktop */
    margin: 0 auto;
    /* Centraliza o card na sua respectiva coluna */
}

.game-card {
    border: 2px solid var(--terminal-dim);
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    width: 150px;
}

.game-card:hover {
    background-color: var(--terminal-green);
    color: var(--bg-color);
    box-shadow: 0 0 15px var(--terminal-green);
}

.game-card .icon {
    color: #00ffff;
    text-shadow: 0 0 5px rgba(0, 255, 255, 0.5);
    transition: color 0.3s;
}

/* Corapagada para o ícone de jogos DESABILITADOS */
.game-card.disabled .icon {
    color: var(--terminal-dim);
    /* Usa o verde escuro que você já tem no :root */
    text-shadow: none;
}

/* Opcional: Deixar o texto do Em Breve... apagado também */
.game-card.disabled small {
    color: var(--terminal-dim);
    opacity: 0.7;
}

.game-card.selected {
    outline: 3px solid #00ffff;
    transform: scale(1.05);
    box-shadow: 0 0 15px #00ffff;
}

/* Container do jogo (tela preta tipo arcade) */
#game-container {
    position: fixed;
    inset: 0;
    background-color: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 5;
}

#game-container,
#settings-menu {
    user-select: none;
    -webkit-user-select: none;
    -ms-user-select: none;
    cursor: default;
}

/* ===============================
   INPUT LAYOUT
================================ */
#input-layout-container {
    margin-top: 32px;
    padding: 24px;
    border: 2px dashed #0f0;
    max-width: 1400px;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

#input-layout {
    width: 100%;
    display: flex;
    justify-content: center;
}

.input-16bit {
    display: flex;
    justify-content: center;
    gap: 120px;
    width: 100%;
}

.mobile-only {
    display: none;
}

/* ===============================
   MOSTRADOR DE ESTATÍSTICAS
================================ */
#debug-overlay {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: #00ff00;
    font-family: monospace;
    padding: 8px;
    font-size: 12px;
    z-index: 9999;
}

/* ===============================
   KEYBOARD
================================ */
.keyboard-16bit.full {
    display: flex;
    gap: 24px;
    padding: 16px 20px;
    background: #050505;
    border: 2px solid #0f0;
    box-shadow: 0 0 18px rgba(0, 255, 0, .25);
}

.kb-block {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.kb-block.arrows {
    margin-top: 115px;
}

.kb-block.numpad {
    display: grid;
    grid-template-columns: repeat(4, 32px);
    grid-auto-rows: 32px;
    gap: 6px;
}

.kb-row {
    display: flex;
    gap: 6px;
    justify-content: center;
}

/* ===============================
   KEYS
================================ */
.kb-key {
    position: relative;
    min-width: 32px;
    height: 32px;
    background: #111;
    border: 2px solid #0f0;
    color: #0f0;
    font-size: 14px;
    text-align: center;
    line-height: 28px;
    transition:
        transform .06s steps(2),
        box-shadow .06s steps(2),
        background .06s steps(2);
}

.kb-key[data-key="space"] {
    min-width: 222px;
}

/* .kb-key.wide {
    min-width: 70px;
}

.kb-key.tall {
    height: 70px;
    line-height: 66px;
} */

.kb-key.mapped {
    border-color: #ff0;
    color: #ff0;
    animation: arcadePulse 1.6s infinite;
}

.kb-key.active {
    background: #0f0;
    color: #000;
    transform: translateY(2px);
    box-shadow:
        0 0 6px rgba(0, 255, 0, .9),
        inset 0 0 6px rgba(0, 0, 0, .6);
    animation: crtPulse .12s steps(2);
}

.kb-key.ghost {
    visibility: hidden;
    border: none;
    background: transparent;
}

/* ===============================
   GAMEPAD DIAGNOSTIC PANEL
================================ */
.gamepad-diagnostic-panel {
    background: rgba(5, 10, 5, 0.85);
    border: 2px solid var(--terminal-dim);
    padding: 20px 30px;
    width: 100%;
    max-width: 550px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: inset 0 0 25px rgba(0, 255, 0, 0.05), 0 10px 30px rgba(0, 0, 0, 0.8);
}

.diagnostic-header {
    width: 100%;
    text-align: left;
    border-bottom: 2px dashed var(--terminal-dim);
    padding-bottom: 10px;
    margin-bottom: 20px;
    color: var(--terminal-green);
    font-size: 1.4rem;
    letter-spacing: 2px;
}

.diagnostic-header .blink {
    color: #ff0055;
    animation: blinkCursor 1s infinite;
    margin-right: 8px;
}

.gamepad-image-wrapper {
    position: relative;
    padding: 30px;
    background: radial-gradient(circle, rgba(0, 255, 204, 0.15) 0%, rgba(0, 0, 0, 0) 60%);
    border-radius: 50%;
    margin-bottom: 20px;
    height: 220px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.gamepad-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    filter: drop-shadow(0px 15px 15px rgba(0, 0, 0, 0.9)) brightness(0.7);
    image-rendering: pixelated;
    transition: filter 0.05s ease, transform 0.05s ease;
}

/* O brilho neon quando um botão é apertado! */
.gamepad-img.input-active {
    filter: drop-shadow(0px 0px 30px rgba(0, 255, 204, 0.9)) brightness(1.2);
    transform: scale(1.03);
}

.diagnostic-info {
    width: 100%;
    background: #020502;
    border: 2px solid var(--terminal-dim);
    padding: 15px;
    text-align: center;
    font-size: 1.2rem;
    box-shadow: inset 0 0 10px rgba(0, 255, 0, 0.1);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ===============================
   LEGEND DISPLAY
================================ */
#legend-display {
    min-width: 220px;
    height: 28px;
    line-height: 28px;
    margin-top: 18px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;

    background: #111;
    border: 2px solid #ffd700;
    color: #ffd700;

    font-family: 'Press Start 2P', monospace;
    font-size: 10px;

    opacity: 0;
    transition:
        opacity 0.15s steps(2),
        box-shadow 0.15s steps(2);
}

#legend-display.active {
    opacity: 1;
    box-shadow: 0 0 12px rgba(255, 215, 0, 0.8);
}

#legend-display[data-type="mouse"] {
    border-color: #0ff;
    color: #0ff;
}

/* ===============================
   MOUSE
================================ */
.mouse-body {
    width: 100px;
    height: 220px;
    border: 2px solid rgba(0, 255, 0, .46);
    border-radius: 12px;
    display: flex;
    justify-content: center;
    box-shadow:
        0 0 14px rgba(0, 255, 0, .35),
        inset 0 0 8px rgba(0, 255, 0, .15);
}

.mouse-btn {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 46px;
    height: 68px;
    line-height: 68px;
    border: 2px solid #0f0;
    background: #0a0a0a;
    color: #0f0;
    transition: transform .06s steps(2), box-shadow .06s steps(2);
}

.mouse-btn.mapped {
    border-color: #ff0;
    color: #ff0;
    animation: arcadePulse 1.6s infinite;
}

.mouse-btn.active {
    background: #0f0;
    color: #000;
    transform: translateY(2px);
    box-shadow: 0 0 10px rgba(0, 255, 0, .9);
    animation: crtPulse .12s steps(2);
}

/* =============================== 
    GAMEPAD
 ================================ */

.gamepad-16bit {
    position: relative;
    width: 500px;
}

.gamepad-bg {
    width: 100%;
    display: block;
}

.btn,
.dpad {
    position: absolute;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    transition: all 0.08s ease;
}

.btn.pressed {
    filter: contrast(200%) saturate(150%);
}

.btn.pressed,
.dpad.pressed {
    transform: scale(0.85);
    filter: brightness(1.6);
    box-shadow: 0 0 10px #00f0ff;
}

/* =============================== 
    CAFÉ DO DEV
 ================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.modal-overlay.hidden {
    display: none;
}

.modal-xatax {
    width: 360px;
    background: #050b14;
    border: 2px solid #00ffff;
    box-shadow: 0 0 20px #00ffff;
    border-radius: 12px;
    font-family: 'Orbitron', sans-serif;
    color: #e0faff;
    animation: scaleIn 0.2s ease-out;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    padding: 12px;
    border-bottom: 1px solid #00ffff;
}

.modal-body {
    padding: 16px;
    text-align: center;
}

.neon-text {
    color: #00ffff;
    text-shadow: 0 0 8px #00ffff;
}

.qrcode-container img {
    width: 180px;
    margin: 12px 0;
    border: 2px solid #00ffff;
}

.pix-container {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.pix-container input {
    flex: 1;
    background: #000;
    border: 1px solid #00ffff;
    color: #00ffff;
    padding: 6px;
}

.btn-copiar {
    background: #00ffff;
    color: #000;
    border: none;
    padding: 6px 10px;
    cursor: pointer;
}

.btn-fechar {
    background: none;
    border: none;
    color: #00ffff;
    font-size: 16px;
    cursor: pointer;
}

/* ===============================
   PINBALL SIDEBAR (INJETADA VIA JS)
================================ */

.pinball-container {
    display: flex;
    gap: 20px;
    width: 100%;
    height: 100%;
    padding: 20px;
    /* Adicione estas duas linhas: */
    max-width: 1200px;
    margin: 0 auto;
}

.pinball-sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
    border: 2px solid var(--terminal-dim);
    padding: 20px;
    background: rgba(0, 20, 0, 0.8);
    /* Adicione limites para a sidebar: */
    flex: 1;
    min-width: 300px;
    max-width: 350px;
}

.pinball-sidebar .panel {
    border: 1px solid var(--terminal-green);
    padding: 15px;
    background: #000;
}

.pinball-sidebar .score-panel h3 {
    text-align: center;
    margin: 0 0 10px 0;
    color: var(--terminal-dim);
    font-size: 1.5rem;
}

.pinball-sidebar .digital-score {
    font-size: 3.5rem;
    text-align: right;
    color: #00ffff;
    text-shadow: 0 0 15px rgba(0, 255, 255, 0.8);
    letter-spacing: 2px;
}

.pinball-sidebar .status-row {
    display: flex;
    justify-content: space-between;
    font-size: 1.5rem;
    padding: 5px 0;
    border-bottom: 1px solid rgba(51, 255, 0, 0.2);
}

.pinball-sidebar .status-row:last-child {
    border-bottom: none;
}

.pinball-sidebar .matrix-display {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 0 15px rgba(51, 255, 0, 0.2);
    background: #020802;
    position: relative;
    /* Necessário para o pseudo-elemento */
    overflow: hidden;
}

/* Cria as linhas de TV antigas por cima do display matriz */
.pinball-sidebar .matrix-display::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.3) 50%);
    background-size: 100% 4px;
    pointer-events: none;
    /* Para não atrapalhar cliques */
}

.pinball-sidebar .matrix-screen {
    color: #00ffcc;
    font-size: 1.2rem;
    line-height: 1.5;
    text-shadow: 0 0 5px #00ffcc;
    animation: crtPulse 2s infinite;
}

.pinball-sidebar .controls-panel {
    margin-top: auto;
}

.pinball-sidebar .status-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* Garante alinhamento vertical */
    font-size: 1.5rem;
    padding: 5px 0;
    border-bottom: 1px solid rgba(51, 255, 0, 0.2);
    white-space: nowrap;
    /* Impede que o texto pule de linha */
}

/* =============================== RODAPÉ FIXO ================================ */
.container-rodape {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 32px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 18px;
    color: var(--terminal-green);
    background-color: rgba(0, 0, 0, 0.25);
    z-index: 100;
    text-shadow: 0 0 5px rgba(0, 229, 255, 0.2);
}