@font-face {
  font-family: 'Press Start 2P';
  src: url('../fontes/press-start-2p.woff2') format('woff2');
  font-display: block;
}

:root {
  --larg: 480;            /* largura interna do jogo (o JS ajusta) */
  --fundo: #0e090d;
  --corpo: #2a1c24;       /* "carcaça" do controle */
  --corpo-claro: #3a2a34;
  --berinjela: #6a2c91;
  --berinjela-clara: #a45fd6;
  --ouro: #ffd43a;
  --texto: #f2e6c8;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  background: var(--fundo);
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- DEITADO (e computador): o jogo ocupa a tela inteira, fora do "notch" ---------- */
#jogo {
  position: fixed;
  top: env(safe-area-inset-top, 0px);
  right: env(safe-area-inset-right, 0px);
  bottom: env(safe-area-inset-bottom, 0px);
  left: env(safe-area-inset-left, 0px);
}

#jogo canvas {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
}

#controles {
  display: none;
}

/* ---------- EM PÉ: tela do jogo em cima, controles grandes embaixo (estilo Game Boy) ---------- */
@media (orientation: portrait) {
  :root {
    /* margem do topo: livra o entalhe da câmera e funciona como a "moldura" da tela do Game Boy */
    --topo: max(env(safe-area-inset-top, 0px), 40px);
  }
  body {
    background: var(--corpo-claro);
  }
  #jogo {
    top: var(--topo);
    left: 6px;
    right: 6px;
    bottom: auto;
    height: calc((100vw - 12px) * 270 / var(--larg));
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 0 0 3px #1c1218, 0 4px 0 3px #1c1218;
  }

  #controles {
    display: grid;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: calc(var(--topo) + (100vw - 12px) * 270 / var(--larg) + 10px);
    padding: 10px 18px calc(18px + env(safe-area-inset-bottom, 0px));
    box-sizing: border-box;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto 1fr auto;
    grid-template-areas:
      'faixa faixa'
      'cruz acoes'
      'dica dica';
    gap: 10px;
    align-items: center; /* cruz e botões juntos, no meio do espaço livre */
    background: linear-gradient(180deg, var(--corpo-claro), var(--corpo) 40%);
    font-family: 'Press Start 2P', monospace;
    color: var(--texto);
    touch-action: none;
  }

  #controles button {
    font: inherit;
    color: var(--texto);
    border: 0;
    cursor: pointer;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
  }

  .faixa {
    grid-area: faixa;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .marca {
    font-size: 11px;
    color: var(--ouro);
    letter-spacing: 1px;
    text-shadow: 2px 2px 0 #1c1218;
  }
  .pausa {
    width: 52px;
    height: 36px;
    border-radius: 18px;
    background: #1c1218;
    box-shadow: inset 0 -3px 0 #000;
    font-size: 12px;
  }

  /* direcional: duas setas grandes */
  .cruz {
    grid-area: cruz;
    display: grid;
    grid-template-columns: repeat(3, auto);
    grid-template-areas:
      '. cima .'
      'esq . dir'
      '. baixo .';
    gap: 4px;
    align-content: center;
    justify-content: start;
  }
  .cruz .cima { grid-area: cima; }
  .cruz .baixo { grid-area: baixo; }
  .cruz .esq { grid-area: esq; }
  .cruz .dir { grid-area: dir; }
  .cruz button {
    width: clamp(48px, 15vw, 70px);
    height: clamp(48px, 15vw, 70px);
    border-radius: 16px;
    background: #1c1218;
    box-shadow: inset 0 -5px 0 #000, 0 3px 0 #4a3540;
    display: grid;
    place-items: center;
  }
  .cruz svg {
    width: 55%;
    height: 55%;
    pointer-events: none;
  }

  /* ações: PULA grande embaixo à direita, TIRO à esquerda dele, CORTA em cima */
  .acoes {
    grid-area: acoes;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    grid-template-areas:
      'corta .'
      'tiro pula';
    gap: 8px 10px;
    align-content: center;
    align-items: center;
    justify-items: center;
  }
  .acoes button {
    width: clamp(62px, 19vw, 88px);
    height: clamp(62px, 19vw, 88px);
    border-radius: 50%;
    font-size: clamp(9px, 2.6vw, 12px);
    box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.45), 0 3px 0 #1c1218;
  }
  .acoes .pula { grid-area: pula; background: #b8282e; width: clamp(72px, 22vw, 100px); height: clamp(72px, 22vw, 100px); }
  .acoes .tiro { grid-area: tiro; background: var(--berinjela); }
  .acoes .corta { grid-area: corta; background: #2d7a3a; }

  #controles button.apertado {
    transform: translateY(3px);
    filter: brightness(1.35);
    box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.45);
  }

  .dica {
    grid-area: dica;
    margin: 0;
    text-align: center;
    font-size: 8px;
    line-height: 1.6;
    color: #8a7a6a;
  }
}

noscript {
  color: var(--texto);
  font-family: monospace;
  display: block;
  padding: 24px;
}
