/* =============================================================
   DINO IA — folha de estilo principal
   Inovalord · design premium, 100% responsivo (320px → 4K)
   Português europeu em todos os comentários.
   ============================================================= */

/* -------------------------------------------------------------
   1. TOKENS DE TEMA
   Tema claro por omissão; escuro por preferência do sistema
   (quando data-theme="auto") ou por escolha explícita.
   ------------------------------------------------------------- */
:root {
  /* Marca */
  --roxo: #7c3aed;
  --roxo-forte: #6d28d9;
  --roxo-claro: #a78bfa;
  --lima: #a3e635;
  --lima-forte: #65a30d;
  --vermelho: #ef4444;
  --ambar: #f59e0b;

  /* Superfícies (claro) */
  --fundo: #f4f3fa;
  --fundo-2: #eceafa;
  --painel: #ffffff;
  --painel-2: #f7f6fd;
  --borda: rgba(17, 12, 40, 0.10);
  --borda-forte: rgba(17, 12, 40, 0.18);

  /* Texto */
  --texto: #14111f;
  --texto-2: #4c4763;
  --texto-3: #7b7594;

  /* Efeitos */
  --sombra-1: 0 1px 2px rgba(20, 15, 45, .06), 0 4px 14px rgba(20, 15, 45, .06);
  --sombra-2: 0 6px 18px rgba(20, 15, 45, .10), 0 22px 50px rgba(20, 15, 45, .10);
  --sombra-roxa: 0 8px 24px rgba(124, 58, 237, .30);
  --brilho: radial-gradient(1200px 600px at 15% -10%, rgba(124, 58, 237, .16), transparent 60%),
            radial-gradient(900px 500px at 100% 0%, rgba(163, 230, 53, .12), transparent 55%);
  --vidro: rgba(255, 255, 255, .72);
  --tela-jogo: linear-gradient(180deg, #ffffff 0%, #f2f0fb 100%);

  /* Medidas */
  --r-xs: 8px;
  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 22px;
  --r-xl: 28px;
  --gap: clamp(10px, 2.2vw, 20px);
  --pad-pagina: clamp(12px, 3vw, 28px);
  --toque: 44px;                     /* alvo mínimo de toque */
  --topo-altura: 58px;

  /* Áreas seguras (iPhone com notch) */
  --sa-t: env(safe-area-inset-top, 0px);
  --sa-r: env(safe-area-inset-right, 0px);
  --sa-b: env(safe-area-inset-bottom, 0px);
  --sa-l: env(safe-area-inset-left, 0px);

  color-scheme: light;
}

/* Escuro automático (segue o sistema) */
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --fundo: #0a0912;
    --fundo-2: #0f0d1c;
    --painel: #14121f;
    --painel-2: #1b1830;
    --borda: rgba(255, 255, 255, .10);
    --borda-forte: rgba(255, 255, 255, .20);
    --texto: #f3f1fb;
    --texto-2: #bdb7d6;
    --texto-3: #8b84ab;
    --sombra-1: 0 1px 2px rgba(0, 0, 0, .5), 0 6px 20px rgba(0, 0, 0, .38);
    --sombra-2: 0 10px 28px rgba(0, 0, 0, .55), 0 30px 70px rgba(0, 0, 0, .45);
    --sombra-roxa: 0 10px 30px rgba(124, 58, 237, .45);
    --brilho: radial-gradient(1100px 620px at 12% -12%, rgba(124, 58, 237, .30), transparent 60%),
              radial-gradient(900px 520px at 100% 0%, rgba(163, 230, 53, .10), transparent 55%);
    --vidro: rgba(20, 18, 31, .74);
    --tela-jogo: linear-gradient(180deg, #171428 0%, #0d0b18 100%);
    color-scheme: dark;
  }
}

/* Escuro forçado pelo utilizador */
:root[data-theme="escuro"] {
  --fundo: #0a0912;
  --fundo-2: #0f0d1c;
  --painel: #14121f;
  --painel-2: #1b1830;
  --borda: rgba(255, 255, 255, .10);
  --borda-forte: rgba(255, 255, 255, .20);
  --texto: #f3f1fb;
  --texto-2: #bdb7d6;
  --texto-3: #8b84ab;
  --sombra-1: 0 1px 2px rgba(0, 0, 0, .5), 0 6px 20px rgba(0, 0, 0, .38);
  --sombra-2: 0 10px 28px rgba(0, 0, 0, .55), 0 30px 70px rgba(0, 0, 0, .45);
  --sombra-roxa: 0 10px 30px rgba(124, 58, 237, .45);
  --brilho: radial-gradient(1100px 620px at 12% -12%, rgba(124, 58, 237, .30), transparent 60%),
            radial-gradient(900px 520px at 100% 0%, rgba(163, 230, 53, .10), transparent 55%);
  --vidro: rgba(20, 18, 31, .74);
  --tela-jogo: linear-gradient(180deg, #171428 0%, #0d0b18 100%);
  color-scheme: dark;
}

/* Claro forçado pelo utilizador (repõe os valores base) */
:root[data-theme="claro"] { color-scheme: light; }


/* -------------------------------------------------------------
   2. REPOSIÇÃO E BASE
   ------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  max-width: 100%;
  overflow-x: hidden;          /* nunca haver deslocamento lateral */
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100svh;
  min-height: 100dvh;
  background: var(--fundo);
  background-image: var(--brilho);
  background-attachment: fixed;
  color: var(--texto);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  padding: 0 var(--sa-r) var(--sa-b) var(--sa-l);
  transition: background-color .3s ease, color .3s ease;
}

img, video, canvas, svg { display: block; max-width: 100%; }

h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.02em; }
p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }

:focus-visible {
  outline: 2px solid var(--roxo);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .92em; }

kbd {
  display: inline-block;
  padding: 2px 7px;
  border: 1px solid var(--borda-forte);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--painel-2);
  font: 600 12px/1.4 ui-monospace, Menlo, Consolas, monospace;
  color: var(--texto);
}


/* -------------------------------------------------------------
   3. CABEÇALHO
   ------------------------------------------------------------- */
.topo {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: var(--topo-altura);
  padding: calc(8px + var(--sa-t)) var(--pad-pagina) 8px;
  background: var(--vidro);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--borda);
}

.topo__marca { display: flex; align-items: center; gap: 10px; min-width: 0; }

.topo__logo {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(140deg, var(--roxo) 0%, var(--roxo-forte) 55%, #4c1d95 100%);
  box-shadow: var(--sombra-roxa);
}

.topo__titulo { display: flex; flex-direction: column; min-width: 0; }
.topo__titulo strong {
  font-size: clamp(15px, 3.6vw, 19px);
  font-weight: 800;
  letter-spacing: .14em;
  white-space: nowrap;
}

.selo-inova {
  display: inline-block;
  align-self: flex-start;
  margin-top: 1px;
  padding: 1px 7px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(124, 58, 237, .16), rgba(163, 230, 53, .16));
  border: 1px solid var(--borda);
  color: var(--texto-2);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .04em;
  white-space: nowrap;
}

.topo__acoes { display: flex; align-items: center; gap: 8px; }


/* -------------------------------------------------------------
   4. BOTÕES
   ------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--toque);
  padding: 10px 16px;
  border: 1px solid var(--borda);
  border-radius: 999px;
  background: var(--painel);
  color: var(--texto);
  font: inherit;
  font-weight: 650;
  font-size: 14px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  box-shadow: var(--sombra-1);
  transition: transform .16s ease, box-shadow .2s ease, background-color .2s ease, border-color .2s ease, opacity .2s ease;
}
.btn:hover { transform: translateY(-1px); border-color: var(--borda-forte); }
.btn:active { transform: translateY(0) scale(.98); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; pointer-events: none; }

.btn--primario {
  border-color: transparent;
  color: #fff;
  background: linear-gradient(135deg, var(--roxo) 0%, var(--roxo-forte) 100%);
  box-shadow: var(--sombra-roxa);
}
.btn--primario:hover { box-shadow: 0 12px 30px rgba(124, 58, 237, .42); }

.btn--secundario { background: var(--painel-2); }

.btn--fantasma { background: transparent; box-shadow: none; }
.btn--fantasma:hover { background: var(--painel-2); }

.btn--icone { padding: 10px 14px; min-width: var(--toque); }
.btn--icone .btn__texto { display: none; }

.btn--fechar {
  min-height: 38px;
  width: 38px;
  padding: 0;
  border-radius: 50%;
  background: var(--painel-2);
  box-shadow: none;
  flex: 0 0 38px;
}

.btn--descarregar { white-space: nowrap; text-decoration: none; }


/* -------------------------------------------------------------
   5. PALCO (grelha principal)
   Telemóvel: uma coluna · Desktop: jogo + coluna lateral
   ------------------------------------------------------------- */
.palco {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gap);
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: var(--gap) var(--pad-pagina) 0;
}

.cartao {
  position: relative;
  background: var(--painel);
  border: 1px solid var(--borda);
  border-radius: var(--r-lg);
  box-shadow: var(--sombra-1);
  padding: clamp(10px, 2.4vw, 16px);
  min-width: 0;
}

.cartao__titulo {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 750;
  letter-spacing: .01em;
  color: var(--texto-2);
}
.cartao__titulo svg { color: var(--roxo); flex: 0 0 auto; }

.coluna-lado { display: grid; gap: var(--gap); min-width: 0; align-content: start; }


/* -------------------------------------------------------------
   6. ÁREA DE JOGO
   ------------------------------------------------------------- */
.jogo {
  position: relative;
  width: 100%;
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--tela-jogo);
  border: 1px solid var(--borda);
  isolation: isolate;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 2 / 1;              /* telemóvel: mais alto para dar presença */
  background: transparent;
  touch-action: manipulation;
}

/* --- HUD sobreposto --- */
.hud {
  position: absolute;
  inset: 8px 8px auto 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
  z-index: 3;
}
.hud__linha { display: flex; flex-wrap: wrap; gap: 6px; }
.hud__linha--2 { justify-content: flex-start; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--borda);
  background: var(--vidro);
  backdrop-filter: blur(10px) saturate(150%);
  -webkit-backdrop-filter: blur(10px) saturate(150%);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.6;
  color: var(--texto-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: var(--sombra-1);
}
.pill b { color: var(--texto); font-size: 13px; font-variant-numeric: tabular-nums; }
.pill__rot { font-size: 9.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--texto-3); }

.pill--pontos b { color: var(--roxo); }
.pill--recorde b { color: var(--texto-2); }
.pill--fps b { font-size: 12px; }

.pill--gesto {
  border-color: rgba(124, 58, 237, .38);
  background: linear-gradient(90deg, rgba(124, 58, 237, .18), rgba(124, 58, 237, .06));
  color: var(--texto);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .02em;
  text-transform: capitalize;
  padding: 5px 12px;
}

/* Estados da câmara */
.pill--estado .ponto {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: var(--texto-3);
  box-shadow: 0 0 0 3px rgba(120, 120, 140, .18);
}
.pill--estado.is-off { color: var(--texto-3); }
.pill--estado.is-on {
  color: var(--lima-forte);
  border-color: rgba(101, 163, 13, .45);
}
.pill--estado.is-on .ponto {
  background: var(--lima);
  box-shadow: 0 0 0 3px rgba(163, 230, 53, .28);
  animation: pulsar 1.8s ease-in-out infinite;
}
.pill--estado.is-err, .pill--estado.is-erro {
  color: var(--vermelho);
  border-color: rgba(239, 68, 68, .45);
}
.pill--estado.is-err .ponto, .pill--estado.is-erro .ponto {
  background: var(--vermelho);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, .25);
}
.pill--estado.is-load, .pill--estado.is-carregar {
  color: var(--ambar);
  border-color: rgba(245, 158, 11, .45);
}
.pill--estado.is-load .ponto, .pill--estado.is-carregar .ponto {
  background: var(--ambar);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, .25);
  animation: pulsar 1s linear infinite;
}

@keyframes pulsar {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.25); opacity: .72; }
}

/* --- Flash de comando enviado --- */
.cmd-flash {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 4;
  pointer-events: none;
  opacity: 0;
}
.cmd-flash__txt {
  padding: 10px 22px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--roxo), var(--roxo-forte));
  color: #fff;
  font-size: clamp(14px, 3.4vw, 20px);
  font-weight: 850;
  letter-spacing: .06em;
  text-transform: uppercase;
  box-shadow: 0 10px 34px rgba(124, 58, 237, .55);
}
/* Classes que o app.js pode alternar para disparar o flash */
.cmd-flash.is-on,
.cmd-flash.ativo,
.cmd-flash.flash {
  animation: flash-cmd .42s ease-out;
}
@keyframes flash-cmd {
  0%   { opacity: 0; }
  12%  { opacity: 1; }
  100% { opacity: 0; }
}
.cmd-flash.is-on .cmd-flash__txt,
.cmd-flash.ativo .cmd-flash__txt,
.cmd-flash.flash .cmd-flash__txt { animation: flash-escala .42s ease-out; }
@keyframes flash-escala {
  0%   { transform: scale(.82); }
  25%  { transform: scale(1.06); }
  100% { transform: scale(1); }
}

/* Anel roxo à volta do jogo quando chega um comando */
.jogo.is-cmd::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 3px rgba(124, 58, 237, .75);
  pointer-events: none;
  animation: flash-cmd .42s ease-out;
}


/* -------------------------------------------------------------
   7. BARRA DE AÇÕES
   ------------------------------------------------------------- */
.acoes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.acoes .btn { flex: 1 1 auto; min-width: 104px; }


/* -------------------------------------------------------------
   8. CÂMARA
   ------------------------------------------------------------- */
.camara {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--painel-2);
  border: 1px solid var(--borda);
}

#camVideo, #camOverlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);            /* efeito espelho, mais natural */
  background: transparent;
}
#camVideo { z-index: 1; }
#camOverlay { z-index: 2; pointer-events: none; }

.camara__vazia {
  position: absolute;
  inset: 0;
  z-index: 0;                        /* fica por trás do vídeo: some quando há imagem */
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 6px;
  padding: 10px;
  text-align: center;
  color: var(--texto-3);
  background: var(--painel-2);
}
.camara__vazia span { font-size: 26px; }
.camara__vazia p { font-size: 11.5px; max-width: 190px; }
.camara.is-live .camara__vazia { opacity: 0; }

.dica {
  margin-top: 8px;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--texto-3);
}


/* -------------------------------------------------------------
   9. LISTA DE GESTOS (coluna lateral)
   ------------------------------------------------------------- */
.lista-gestos { display: grid; gap: 6px; }
.lista-gestos li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--r-sm);
  background: var(--painel-2);
  border: 1px solid transparent;
  transition: border-color .2s ease, transform .2s ease;
}
.lista-gestos li:hover { border-color: var(--borda); transform: translateX(2px); }
.lista-gestos .emoji { font-size: 20px; line-height: 1; flex: 0 0 auto; }
.lista-gestos__txt { display: flex; flex-direction: column; min-width: 0; }
.lista-gestos__txt b { font-size: 12.5px; }
.lista-gestos__txt small { font-size: 11px; color: var(--texto-3); }


/* -------------------------------------------------------------
   10. SECÇÃO DA APP PARA WINDOWS
   ------------------------------------------------------------- */
.rodape-app {
  display: grid;
  gap: 14px;
  align-items: center;
  width: 100%;
  max-width: 1440px;
  margin: var(--gap) auto 0;
  padding: clamp(16px, 3.4vw, 26px);
  border: 1px solid var(--borda);
  border-radius: var(--r-lg);
  background:
    linear-gradient(135deg, rgba(124, 58, 237, .10), rgba(163, 230, 53, .07)),
    var(--painel);
  box-shadow: var(--sombra-1);
}
/* margem lateral igual à do palco */
.rodape-app, .creditos { margin-left: auto; margin-right: auto; }
.palco, .rodape-app { padding-left: var(--pad-pagina); padding-right: var(--pad-pagina); }

.rodape-app h2 { font-size: clamp(16px, 3.6vw, 21px); font-weight: 800; margin-bottom: 6px; }
.rodape-app h2 em { color: var(--roxo); font-style: normal; }
.rodape-app p { font-size: 13px; color: var(--texto-2); }
.rodape-app .requisitos { margin-top: 8px; font-size: 12px; color: var(--texto-3); }

.creditos {
  width: 100%;
  max-width: 1440px;
  padding: 22px var(--pad-pagina) calc(28px + var(--sa-b));
  text-align: center;
  font-size: 12px;
  color: var(--texto-3);
}


/* -------------------------------------------------------------
   11. MODAIS
   Telemóvel: ecrã inteiro com deslocamento interno.
   Desktop: caixa centrada.
   ------------------------------------------------------------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal[hidden] { display: none; }

.modal__fundo {
  position: absolute;
  inset: 0;
  background: rgba(8, 6, 18, .58);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: aparecer .22s ease;
}

.modal__caixa {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 560px;
  max-height: 100svh;
  max-height: 100dvh;
  background: var(--painel);
  border: 1px solid var(--borda);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--sombra-2);
  overflow: hidden;
  animation: subir .26s cubic-bezier(.22, 1, .36, 1);
}

.modal__topo {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px calc(14px - 2px);
  padding-top: calc(14px + var(--sa-t));
  border-bottom: 1px solid var(--borda);
  background: var(--painel);
}
.modal__topo h2 { font-size: 17px; font-weight: 800; }

.modal__corpo {
  padding: 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  flex: 1 1 auto;
}

.modal__intro { font-size: 13.5px; color: var(--texto-2); margin-bottom: 14px; }
.modal__sub {
  margin: 18px 0 10px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--texto-3);
}
.modal__sub:first-child { margin-top: 0; }
.modal__nota { font-size: 13px; color: var(--texto-2); }

.modal__fundo-acoes {
  padding: 12px 16px calc(14px + var(--sa-b));
  border-top: 1px solid var(--borda);
  background: var(--painel);
}
.modal__fundo-acoes .btn { width: 100%; }

@keyframes aparecer { from { opacity: 0; } to { opacity: 1; } }
@keyframes subir { from { transform: translateY(24px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }


/* --- Grelha de gestos (instruções) --- */
.gestos-grelha {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.gesto-cartao {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 14px 12px;
  border-radius: var(--r-md);
  background: var(--painel-2);
  border: 1px solid var(--borda);
  text-align: center;
  align-items: center;
}
.gesto-cartao__emoji { font-size: 32px; line-height: 1.1; }
.gesto-cartao b { font-size: 13px; }
.gesto-cartao small { font-size: 11.5px; color: var(--texto-3); }
.gesto-cartao--destaque {
  border-color: rgba(124, 58, 237, .40);
  background: linear-gradient(160deg, rgba(124, 58, 237, .14), var(--painel-2));
}
.gesto-cartao--destaque small { color: var(--roxo); font-weight: 750; }

/* --- Dicas --- */
.dicas { display: grid; gap: 8px; }
.dicas li {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  font-size: 13px;
  color: var(--texto-2);
}
.dicas__ico { flex: 0 0 auto; }


/* --- Campos de configuração --- */
.campo { margin-bottom: 16px; }
.campo > label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
  font-size: 13.5px;
  font-weight: 650;
}
.campo small { display: block; margin-top: 5px; font-size: 11.5px; color: var(--texto-3); }
.campo__valor {
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--painel-2);
  border: 1px solid var(--borda);
  font-size: 12px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  color: var(--roxo);
}

.campo--linha {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.campo--linha > label { margin-bottom: 0; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 26px;                 /* área de toque confortável */
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--roxo) 0%, var(--roxo-claro) 100%), var(--painel-2);
  background-blend-mode: normal;
  border: 1px solid var(--borda);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -9px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--roxo);
  box-shadow: 0 2px 8px rgba(124, 58, 237, .45);
  transition: transform .15s ease;
}
input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.12); }
input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--roxo), var(--roxo-claro));
  border: 1px solid var(--borda);
}
input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--roxo);
  box-shadow: 0 2px 8px rgba(124, 58, 237, .45);
}

select {
  min-height: var(--toque);
  padding: 8px 34px 8px 12px;
  border: 1px solid var(--borda-forte);
  border-radius: var(--r-sm);
  background-color: var(--painel-2);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237c3aed' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
  color: var(--texto);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  max-width: 100%;
}


/* --- Modal de calibração --- */
.modal--calib { align-items: center; }
.modal__caixa--estreita {
  max-width: 380px;
  border-radius: var(--r-xl);
  margin: 16px;
}
.calib { padding: 30px 22px 26px; text-align: center; }
.calib__emoji { font-size: 46px; animation: acenar 1.6s ease-in-out infinite; }
.calib h2 { margin: 10px 0 6px; font-size: 19px; font-weight: 800; }
.calib__texto { font-size: 13.5px; color: var(--texto-2); }
.calib__contagem {
  margin: 16px auto 12px;
  width: 92px;
  height: 92px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--roxo), var(--roxo-forte));
  color: #fff;
  font-size: 42px;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
  box-shadow: var(--sombra-roxa);
  animation: bater 1s ease-in-out infinite;
}
.calib__barra {
  height: 7px;
  border-radius: 999px;
  background: var(--painel-2);
  border: 1px solid var(--borda);
  overflow: hidden;
}
.calib__barra > i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--roxo), var(--lima));
  animation: encher 3s linear forwards;
}
.calib__nota { margin-top: 12px; font-size: 11.5px; color: var(--texto-3); }

@keyframes acenar { 0%, 100% { transform: rotate(-9deg); } 50% { transform: rotate(9deg); } }
@keyframes bater { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
@keyframes encher { from { width: 0; } to { width: 100%; } }


/* =============================================================
   12. PONTOS DE QUEBRA
   ============================================================= */

/* --- Telemóvel muito estreito (≤ 359px) --- */
@media (max-width: 359px) {
  :root { --pad-pagina: 10px; --gap: 10px; }
  body { font-size: 14px; }
  .topo__logo { width: 32px; height: 32px; flex-basis: 32px; }
  .selo-inova { display: none; }
  .acoes .btn { min-width: 0; flex: 1 1 100%; }
  .pill--fps { display: none; }              /* poupa espaço no HUD */
  .gestos-grelha { grid-template-columns: 1fr 1fr; }
  .gesto-cartao__emoji { font-size: 26px; }
}

/* --- Telemóvel: HUD FORA do canvas (não tapa o jogo nem o score) --- */
@media (max-width: 767px) {
  .hud {
    position: static;
    inset: auto;
    margin: 0 0 8px;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    pointer-events: auto;
  }
  .hud__linha { flex: 0 1 auto; }
  /* o jogo precisa de presença mesmo em ecrãs estreitos */
  #gameCanvas { aspect-ratio: 16 / 9; min-height: 200px; }
}

/* --- Telemóvel: câmara em PiP flutuante (≤ 767px) --- */
@media (max-width: 767px) {
  /* enquanto a câmara não está ligada, o cartão fica no fluxo (não tapa os botões) */
  .cartao--camara:not(.cam-ativa) { position: static; width: auto; }
  .cartao--camara.cam-ativa {
    position: fixed;
    right: calc(10px + var(--sa-r));
    bottom: calc(12px + var(--sa-b));
    z-index: 60;
    width: clamp(104px, 30vw, 148px);
    padding: 5px;
    border-radius: var(--r-md);
    border-color: var(--borda-forte);
    background: var(--vidro);
    backdrop-filter: blur(14px) saturate(160%);
    -webkit-backdrop-filter: blur(14px) saturate(160%);
    box-shadow: var(--sombra-2);
  }
  .cartao--camara.cam-ativa .cartao__titulo,
  .cartao--camara.cam-ativa .dica { display: none; }   /* PiP só mostra a imagem */
  .cartao--camara.cam-ativa .camara { border-radius: var(--r-sm); aspect-ratio: 3 / 4; }
  /* antes de ligar, o cartão da câmara fica discreto no fluxo */
  .cartao--camara:not(.cam-ativa) .camara { aspect-ratio: 16 / 9; max-height: 150px; }
  .camara__vazia p { display: none; }
  .camara__vazia span { font-size: 20px; }

  /* espaço para o PiP não tapar o conteúdo do fim da página */
  .creditos { padding-bottom: calc(96px + var(--sa-b)); }
  main > :last-child, .cartao:last-of-type { margin-bottom: calc(84px + var(--sa-b)); }

  /* o cartão dos gestos ocupa a linha toda */
  .lista-gestos { grid-template-columns: 1fr 1fr; display: grid; }
}

/* --- Telemóvel grande (≥ 390px) --- */
@media (min-width: 390px) {
  .acoes .btn { min-width: 120px; }
  .camara__vazia p { display: block; }
}

/* --- Tablet (≥ 600px) --- */
@media (min-width: 600px) {
  #gameCanvas { aspect-ratio: 5 / 2; }
  .btn--icone .btn__texto { display: inline; }
  .btn--icone { padding: 10px 16px; }
  .modal { align-items: center; padding: 20px; }
  .modal__caixa {
    border-radius: var(--r-xl);
    max-height: min(88svh, 88dvh);
  }
  .modal__topo { padding-top: 16px; }
  .modal__fundo-acoes { padding-bottom: 16px; }
  .modal__fundo-acoes .btn { width: auto; min-width: 180px; float: right; }
  .modal__fundo-acoes::after { content: ""; display: block; clear: both; }
  .rodape-app { grid-template-columns: minmax(0, 1fr) auto; }
}

/* --- Desktop (≥ 1024px) --- */
@media (min-width: 1024px) {
  :root { --topo-altura: 66px; }

  .palco {
    grid-template-columns: minmax(0, 1fr) clamp(280px, 26vw, 360px);
    align-items: start;
  }
  .cartao--jogo { position: sticky; top: calc(var(--topo-altura) + 12px); }
  #gameCanvas { aspect-ratio: 3 / 1; }

  .hud { inset: 12px 12px auto 12px; flex-direction: row; align-items: flex-start; justify-content: space-between; }
  .hud__linha--2 { justify-content: flex-end; }
  .pill { font-size: 12px; padding: 5px 12px; }
  .pill b { font-size: 15px; }
  .pill--gesto { font-size: 13px; }

  .acoes { margin-top: 14px; }
  .acoes .btn { flex: 0 1 auto; min-width: 132px; }

  .camara { aspect-ratio: 4 / 3; }
  .lista-gestos li { padding: 9px 12px; }
  .lista-gestos__txt b { font-size: 13px; }
}

/* --- Ecrãs largos (≥ 1440px) --- */
@media (min-width: 1440px) {
  body { font-size: 16px; }
  .cartao { padding: 18px; }
}

/* --- Telemóvel deitado e pouca altura --- */
@media (max-height: 480px) and (orientation: landscape) {
  .topo { position: static; }
  #gameCanvas { aspect-ratio: 16 / 5; }
  .cartao--gestos { display: none; }
  .modal__caixa { max-height: 100svh; max-height: 100dvh; }
}


/* -------------------------------------------------------------
   13. ACESSIBILIDADE — movimento reduzido
   ------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  .cmd-flash.is-on, .cmd-flash.ativo, .cmd-flash.flash { opacity: 1; }
  .calib__barra > i { width: 100%; }
}

/* -------------------------------------------------------------
   14. IMPRESSÃO (raro, mas fica limpo)
   ------------------------------------------------------------- */
@media print {
  .topo__acoes, .acoes, .cartao--camara, .modal, .rodape-app { display: none !important; }
  body { background: #fff; color: #000; }
}
