/* ==========================================================================
   Ravi 1·2·3 — apresentação
   --------------------------------------------------------------------------
   Praticamente tudo que se vê é desenhado no canvas. O CSS só faz três
   coisas: pintar o letterbox, escalar o buffer 320×200 com nearest-neighbor
   e posicionar os botões de HUD (som / tela cheia).
   Sem web fonts, sem @import, sem backdrop-filter.
   ========================================================================== */

:root {
  --sw: 320px;   /* largura escalada, calculada por screen.js */
  --sh: 200px;   /* altura escalada */
  --hud: #f8e8a0;
  --hud-face: #1a2458;
  --hud-edge: #f0c040;
  --hud-ink: #f8f0d0;
}

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

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  /* Letterbox com vinheta suave — casa com a paleta navy/noite do jogo */
  background:
    radial-gradient(ellipse 80% 70% at 50% 45%, #142048 0%, #050814 70%, #000 100%);
  color: var(--hud);
  font: 600 14px/1.4 "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* shared.css usa flex + padding; o jogo precisa de letterbox fullscreen preto */
body {
  position: relative;
  padding: 0 !important;
  display: block !important;
  background-image: none !important;
  align-items: stretch !important;
}

/* Shell compartilhado: faixa fina sobre o jogo, sem roubar cliques do canvas */
header[data-lab-header] {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  margin: 0 !important;
  max-width: none !important;
  padding: max(0.65rem, env(safe-area-inset-top)) 0.75rem 0.5rem !important;
  grid-template-columns: auto 1fr auto !important;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.75), transparent);
  pointer-events: none;
}

header[data-lab-header] > * {
  pointer-events: auto;
}

header[data-lab-header] .back-link {
  min-width: 44px;
  min-height: 44px;
}

header[data-lab-header] .app-logo,
header[data-lab-header] h1 {
  font-size: 0.95rem !important;
  color: #fff !important;
}

header[data-lab-header] .subtitle {
  display: none;
}

#app {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#frame {
  width: var(--sw);
  height: var(--sh);
  line-height: 0;
  /* Moldura fina dourada ao redor do CRT */
  box-shadow:
    0 0 0 2px #0a1028,
    0 0 0 4px #c89830,
    0 0 0 6px #1a2458,
    0 12px 40px rgba(0, 0, 0, 0.55);
  border-radius: 2px;
}

/* O canvas mantém o backing store em 320×200; quem amplia é o navegador,
   na GPU, com vizinho mais próximo. */
#screen {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #000;
}

#hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  gap: 8px;
  /* abaixo do header compartilhado (voltar + tema). Em px porque o rem daqui
     acompanha a fonte do jogo: em 3.1rem os botões subiam para cima do
     seletor de tema. */
  padding: calc(60px + env(safe-area-inset-top, 0px)) 12px 10px;
  padding-right: calc(12px + env(safe-area-inset-right, 0px));
  padding-left: calc(12px + env(safe-area-inset-left, 0px));
  pointer-events: none;
}

.hud-spacer {
  flex: 1;
}

.hud-btn {
  pointer-events: auto;
  width: 44px;
  height: 44px;
  border: 2px solid var(--hud-edge);
  border-radius: 6px;
  background:
    linear-gradient(180deg, #2a3878 0%, var(--hud-face) 55%, #0e1638 100%);
  color: var(--hud-ink);
  font: inherit;
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    inset 0 -2px 0 rgba(0, 0, 0, 0.35),
    0 2px 0 #0a1028;
  transition: filter 120ms linear, border-color 120ms linear, transform 80ms linear;
}

.hud-btn:hover,
.hud-btn:focus-visible {
  filter: brightness(1.12);
  border-color: #ffe080;
  outline: none;
}

.hud-btn:active {
  transform: translateY(1px);
  box-shadow:
    inset 0 2px 0 rgba(0, 0, 0, 0.35),
    0 1px 0 #0a1028;
}

.hud-btn[aria-pressed="true"] {
  /* som ligado: nota dourada */
  color: #ffe080;
}

.hud-btn[aria-pressed="false"] {
  /* som mudo */
  color: #7a8498;
  border-color: #4a5578;
  filter: saturate(0.7);
}

#rotate-hint {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  text-align: center;
  padding: 0 16px;
  font-size: 0.85rem;
  color: #b8c4e0;
  text-shadow: 0 1px 2px #000;
}

/* Em celular de pé o palco 320×200 vira uma faixa estreita: vale avisar. */
@media (max-width: 700px) and (orientation: portrait) {
  #rotate-hint {
    display: block;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hud-btn {
    transition: none;
  }
}

/* Região só para leitor de tela: o texto da barra de diálogo é espelhado aqui, já que o
   jogo inteiro é pintado num canvas e nada dele chega à árvore de acessibilidade. */
.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;
}
/* --- lab-responsive-pass --- */
#hud { z-index: 30; }

/* agent-responsive-768 */
@media (max-width: 768px) {
  html, body { overflow-x: clip; }
  .hud, .overlay, .menu-overlay, .overlay-card {
    max-width: 100%;
  }
}
