  /* ==================================================================
     VARIÁVEIS GLOBAIS
     Centraliza as cores e a fonte para manter consistência
     e facilitar ajustes futuros.
     ================================================================== */
  :root {
    --cor-fundo: #000000;
    --cor-fundo-caixa: #0a0a0a;
    --cor-destaque: #4deeff;
    --cor-azul: #5fc9ff;
    --cor-vermelha: #ff6161;
    --fonte-mono: 'Courier New', Courier, 'Lucida Console', Consolas, monospace;
  }

  /* ==================================================================
     RESET BÁSICO
     ================================================================== */
  *,
  *::before,
  *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
  }

  html,
  body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--cor-fundo);
  }

  body {
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--fonte-mono);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
  }

  /* ==================================================================
     ATMOSFERA DE FUNDO
     Scanlines sutis e uma vinheta radial, ambas geradas apenas
     em CSS (sem imagens), para reforçar a sensação de um
     terminal antigo observado de perto.
     ================================================================== */
  body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background: repeating-linear-gradient(
      to bottom,
      rgba(77, 238, 255, 0.035),
      rgba(77, 238, 255, 0.035) 1px,
      transparent 1px,
      transparent 3px
    );
  }

  body::after {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background: radial-gradient(ellipse at center, transparent 35%, rgba(0, 0, 0, 0.85) 145%);
  }

  /* ==================================================================
     CHUVA DE CÓDIGO (fundo estilo Matrix)
     Fica atrás do conteúdo principal (z-index 0) e por baixo das
     scanlines/vinheta acima (z-index 1), para não competir com o
     texto em primeiro plano.
     ================================================================== */
  #chuva-codigo {
    position: fixed;
    inset: 0;
    z-index: 0;
    display: block;
  }

  /* ==================================================================
     TREMOR DE TELA
     Disparado quando o sistema "rejeita" a escolha do usuário.
     ================================================================== */
  @keyframes tremor {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-6px); }
    20%, 40%, 60%, 80% { transform: translateX(6px); }
  }

  body.tremendo {
    animation: tremor 0.45s ease;
  }

  /* ==================================================================
     CONTAINER PRINCIPAL
     Começa invisível e é revelado por transição via JavaScript,
     assim que o documento estiver pronto.
     ================================================================== */
  .portal {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(1.5rem, 4vh, 2.75rem);
    padding: 2rem 1.5rem;
    text-align: center;
    opacity: 0;
    transition: opacity 0.8s ease;
  }

  .portal.visivel {
    opacity: 1;
  }

  /* Uma "poça" escura e suave atrás do texto e dos botões, apenas
     para garantir contraste sobre a chuva de código em movimento.
     Fica atrás dos elementos do próprio .portal (z-index -1), mas
     à frente do canvas e da vinheta (que estão em z-index 0 e 1). */
  .portal::before {
    content: '';
    position: absolute;
    inset: -3rem -4rem;
    z-index: -1;
    pointer-events: none;
    background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.6) 0%, rgba(0, 0, 0, 0.28) 55%, transparent 80%);
  }

  /* ==================================================================
     LINHA DIGITADA + CURSOR
     ================================================================== */
  .linha-digitada {
    display: inline-flex;
    align-items: baseline;
    justify-content: center;
    flex-wrap: wrap;
    color: var(--cor-destaque);
    font-size: clamp(1.15rem, 4.6vw, 2.35rem);
    letter-spacing: 0.04em;
    text-shadow:
      0 0 5px rgba(77, 238, 255, 0.85),
      0 0 16px rgba(77, 238, 255, 0.45),
      0 0 32px rgba(77, 238, 255, 0.25);
  }

  .cursor {
    display: inline-block;
    margin-left: 0.12em;
    animation: piscar 0.9s step-end infinite;
  }

  @keyframes piscar {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0; }
  }

  /* Texto alternativo para leitores de tela, já que a versão
     visual é revelada caractere a caractere. */
  .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  /* ==================================================================
     PALAVRA "ENTRAR"
     ================================================================== */
  .entrar {
    color: var(--cor-destaque);
    font-size: clamp(0.95rem, 3vw, 1.3rem);
    letter-spacing: 0.35em;
    text-transform: uppercase;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 1s ease, transform 1s ease;
    text-shadow: 0 0 8px rgba(77, 238, 255, 0.55);
  }

  .entrar.visivel {
    opacity: 0.85;
    transform: translateY(0);
  }

  /* ==================================================================
     BOTÕES EM FORMATO DE PÍLULA (referência às pílulas da Matrix)
     ================================================================== */
  .botoes {
    display: flex;
    gap: 1.25rem;
    flex-wrap: wrap;
    justify-content: center;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 1s ease, transform 1s ease;
    pointer-events: none;
  }

  .botoes.visivel {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
  }

  .pilula {
    font-family: inherit;
    font-size: clamp(0.8rem, 2vw, 0.95rem);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    padding: 0.9em 2.6em;
    border-radius: 999px;
    background: transparent;
    cursor: pointer;
    outline: none;
    touch-action: manipulation;
    transition: box-shadow 0.35s ease, background-color 0.35s ease, transform 0.2s ease;
  }

  .pilula:active {
    transform: scale(0.96);
  }

  .pilula.azul {
    color: var(--cor-azul);
    border: 1px solid rgba(95, 201, 255, 0.65);
    box-shadow: 0 0 10px rgba(95, 201, 255, 0.3), inset 0 0 8px rgba(95, 201, 255, 0.05);
  }

  .pilula.azul:hover,
  .pilula.azul:focus-visible {
    background: rgba(95, 201, 255, 0.08);
    box-shadow: 0 0 24px rgba(95, 201, 255, 0.75), inset 0 0 14px rgba(95, 201, 255, 0.15);
  }

  .pilula.vermelha {
    color: var(--cor-vermelha);
    border: 1px solid rgba(255, 97, 97, 0.65);
    box-shadow: 0 0 10px rgba(255, 97, 97, 0.3), inset 0 0 8px rgba(255, 97, 97, 0.05);
  }

  .pilula.vermelha:hover,
  .pilula.vermelha:focus-visible {
    background: rgba(255, 97, 97, 0.08);
    box-shadow: 0 0 24px rgba(255, 97, 97, 0.75), inset 0 0 14px rgba(255, 97, 97, 0.15);
  }

  /* ==================================================================
     DICA QUE SEGUE O CURSOR
     Convite discreto pra clicar (e assim liberar a música), visível
     só em telas com mouse de verdade — em toque, não faz sentido.
     ================================================================== */
  .dica-cursor {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 60;
    pointer-events: none;
    color: rgba(255, 255, 255, 0.78);
    font-family: var(--fonte-mono);
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-shadow: 0 0 6px rgba(255, 255, 255, 0.4), 0 0 14px rgba(255, 255, 255, 0.15);
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.4s ease;
    transform: translate(-9999px, -9999px);
    will-change: transform;
  }

  .dica-cursor.visivel {
    opacity: 1;
  }

  @media (hover: none), (pointer: coarse) {
    .dica-cursor {
      display: none;
    }
  }

  /* ==================================================================
     CONTROLE DE ÁUDIO
     Botão discreto, fixo no canto, para ligar/desligar a música
     de fundo a qualquer momento.
     ================================================================== */
  .controle-audio {
    position: fixed;
    right: clamp(1rem, 3vw, 1.75rem);
    bottom: clamp(1rem, 3vw, 1.75rem);
    z-index: 3;
    background: transparent;
    border: 1px solid rgba(77, 238, 255, 0.35);
    color: rgba(77, 238, 255, 0.75);
    font-family: var(--fonte-mono);
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    padding: 0.5em 0.9em;
    border-radius: 999px;
    cursor: pointer;
    outline: none;
    touch-action: manipulation;
    opacity: 0;
    transition: opacity 1s ease, color 0.2s ease, border-color 0.2s ease;
  }

  .controle-audio.visivel {
    opacity: 0.7;
  }

  .controle-audio:hover,
  .controle-audio:focus-visible {
    opacity: 1;
    color: var(--cor-destaque);
    border-color: rgba(77, 238, 255, 0.75);
  }

  /* ==================================================================
     POP-UP DE ERRO
     ================================================================== */
  .erro-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: rgba(0, 0, 0, 0.78);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
  }

  .erro-overlay.ativo {
    opacity: 1;
    visibility: visible;
  }

  .erro-caixa {
    position: relative;
    width: 100%;
    max-width: 420px;
    background: var(--cor-fundo-caixa);
    border: 1px solid rgba(255, 80, 80, 0.5);
    border-radius: 4px;
    padding: 2.1rem 1.75rem 1.85rem;
    box-shadow: 0 0 30px rgba(255, 60, 60, 0.2), 0 10px 40px rgba(0, 0, 0, 0.7);
    transform: scale(0.94);
    transition: transform 0.3s ease;
  }

  .erro-overlay.ativo .erro-caixa {
    transform: scale(1);
  }

  .erro-rotulo {
    display: block;
    color: rgba(255, 100, 100, 0.85);
    font-size: 0.7rem;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    margin-bottom: 0.9rem;
  }

  .erro-mensagem {
    color: var(--cor-destaque);
    font-size: clamp(0.82rem, 2.2vw, 0.95rem);
    line-height: 1.65;
    letter-spacing: 0.01em;
    text-shadow: 0 0 6px rgba(77, 238, 255, 0.45);
  }

  .erro-fechar {
    position: absolute;
    top: 0.4rem;
    right: 0.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    background: none;
    border: none;
    outline: none;
    font-family: inherit;
    font-size: 1.15rem;
    line-height: 1;
    color: rgba(77, 238, 255, 0.55);
    cursor: pointer;
    touch-action: manipulation;
    transition: color 0.2s ease;
  }

  .erro-fechar:hover,
  .erro-fechar:focus-visible {
    color: var(--cor-destaque);
  }

  /* ==================================================================
     AJUSTES RESPONSIVOS
     ================================================================== */
  @media (max-height: 480px) {
    .portal {
      gap: 1.1rem;
    }
  }

  @media (max-width: 340px) {
    .pilula {
      padding: 0.8em 1.8em;
    }
  }

  /* Respeita a preferência do sistema por menos movimento */
  @media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
    }
  }
