/* Guerra dos Esguichos — HUD e ecrãs por cima do 3D.
   Usa os tokens e a escala de letra do hub (/assets/base.css, --fs-*): caixa de brinquedos à luz do dia.
   Regra da casa: cabe tudo num ecrã, sem scroll, no telemóvel deitado e em pé. */

:root {
  --edge: #17153b;
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; height: 100dvh; overflow: hidden; }
body.game-page {
  position: fixed; inset: 0; background: #bfe9ff; color: var(--ink);
  font-family: var(--font); touch-action: none; user-select: none; -webkit-user-select: none; overscroll-behavior: none;
}
html.touch .pc-only, html:not(.touch) .touch-only { display: none !important; }
.hidden { display: none !important; }

#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

/* ── HUD ── */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#mira { position: absolute; left: 50%; top: 50%; width: 26px; height: 26px; transform: translate(-50%, -50%); }
#mira i {
  position: absolute; background: #fffdf5; box-shadow: 0 0 0 1.5px rgba(23, 21, 59, .55); border-radius: 2px;
}
#mira i:nth-child(1) { left: 50%; top: 0; width: 2px; height: 8px; margin-left: -1px; }
#mira i:nth-child(2) { left: 50%; bottom: 0; width: 2px; height: 8px; margin-left: -1px; }
#mira i:nth-child(3) { top: 50%; left: 0; width: 8px; height: 2px; margin-top: -1px; }
#mira i:nth-child(4) { top: 50%; right: 0; width: 8px; height: 2px; margin-top: -1px; }
#mira b { position: absolute; left: 50%; top: 50%; width: 4px; height: 4px; margin: -2px 0 0 -2px; border-radius: 50%; background: #fffdf5; box-shadow: 0 0 0 1.5px rgba(23, 21, 59, .55); opacity: 0; }
#mira.espuma { width: 40px; height: 40px; }
#mira.espuma i { background: #f2f5ff; }
#mira.alvo i { background: var(--pink, #ff4f9a); box-shadow: 0 0 0 1.5px #fffdf5; }
#mira.alvo b { opacity: 1; background: var(--pink, #ff4f9a); }
#hud.escorrer #mira { opacity: .25; }
#mira.acertou i { background: var(--yellow); transform: scale(1.35); }

.tb-btn {
  pointer-events: auto; position: absolute; top: max(8px, var(--safe-t)); left: max(8px, var(--safe-l));
  width: 40px; height: 40px; border-radius: 12px; border: 2px solid var(--edge); background: rgba(255, 253, 245, .9);
  box-shadow: 0 3px 0 var(--edge); font-size: var(--fs-lg); line-height: 1; cursor: pointer;
}
/* ── ecrã molhado: quanto mais molhado, mais água no vidro ── */
#gota {
  position: absolute; inset: 0; opacity: 0; transition: opacity .25s linear; pointer-events: none;
  background:
    radial-gradient(circle at 18% 22%, rgba(120, 205, 255, .55) 0 7px, transparent 8px),
    radial-gradient(circle at 74% 16%, rgba(120, 205, 255, .5) 0 10px, transparent 11px),
    radial-gradient(circle at 36% 78%, rgba(120, 205, 255, .5) 0 9px, transparent 10px),
    radial-gradient(circle at 88% 64%, rgba(120, 205, 255, .5) 0 6px, transparent 7px),
    radial-gradient(circle at 56% 44%, rgba(120, 205, 255, .35) 0 5px, transparent 6px),
    radial-gradient(ellipse at 50% 50%, transparent 38%, rgba(60, 170, 235, .55) 100%);
}
#hud.escorrer #gota { opacity: .85 !important; }

/* ── colunas do HUD ── */
#direita {
  position: absolute; top: max(8px, var(--safe-t)); right: max(8px, var(--safe-r));
  display: grid; gap: 6px; justify-items: end; max-width: 46vw;
}
#topo {
  position: absolute; top: max(8px, var(--safe-t)); left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px; padding: 5px 12px; border-radius: 12px;
  border: 2px solid var(--edge); background: rgba(255, 253, 245, .9); box-shadow: 0 3px 0 var(--edge);
  font-variant-numeric: tabular-nums;
}
#relogio { font: 800 var(--fs-lg)/1 var(--display); }
#meusBanhos { font-size: var(--fs-xs); font-weight: 700; color: var(--ink-2); }

#molhado {
  position: absolute; top: calc(max(8px, var(--safe-t)) + 48px); left: max(8px, var(--safe-l));
  width: clamp(120px, 26vw, 200px);
}
#molhado .barra {
  height: 14px; border-radius: 9px; border: 2px solid var(--edge); background: rgba(255, 253, 245, .85);
  box-shadow: 0 3px 0 var(--edge); overflow: hidden;
}
#molhadoBarra { display: block; height: 100%; width: 0; background: var(--blue); transition: width .12s linear; }
#molhadoBarra.muito { background: var(--pink, #ff4f9a); }
#molhado span { display: block; margin-top: 3px; font-size: var(--fs-3xs); font-weight: 700; color: var(--ink-2); text-shadow: 0 1px 0 rgba(255, 253, 245, .9); }

#armaCartao {
  display: flex; align-items: center; gap: 7px; padding: 5px 11px; border-radius: 12px;
  border: 2px solid var(--edge); background: rgba(255, 253, 245, .9); box-shadow: 0 3px 0 var(--edge);
  font-size: var(--fs-xs); font-weight: 700; white-space: nowrap;
}
#armaCartao.bidao { background: var(--mint, #19c39c); color: #fff; }
#armaEmoji { font-size: var(--fs-lg); line-height: 1; }
#armaMun { font: 800 var(--fs-lg)/1 var(--display); font-variant-numeric: tabular-nums; min-width: 1.6em; text-align: right; }
#armaMun.vazio { color: var(--pink, #ff4f9a); }

#placar { font-size: var(--fs-3xs); font-weight: 700; }
#placar ol { margin: 0; padding: 4px 9px; list-style: none; border-radius: 11px; border: 2px solid var(--edge); background: rgba(255, 253, 245, .8); display: grid; gap: 1px; }
#placar li { white-space: nowrap; }
#placar li.eu { color: var(--blue); }
#placar b { display: inline-block; min-width: 1.4em; font-variant-numeric: tabular-nums; }

#banhoAviso {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%);
  padding: 12px 20px; border-radius: 16px; border: 3px solid var(--edge); background: var(--blue); color: #fff;
  font: 800 var(--fs-lg)/1.25 var(--display); box-shadow: 0 5px 0 var(--edge); max-width: 80vw; text-align: center;
}
#feed {
  position: absolute; left: 50%; bottom: calc(max(10px, var(--safe-b)) + 52px); transform: translateX(-50%);
  display: grid; gap: 4px; justify-items: center; max-width: min(520px, 80vw); pointer-events: none;
}
#feed div {
  padding: 5px 11px; border-radius: 11px; border: 2px solid var(--edge); background: rgba(255, 253, 245, .92);
  font-size: var(--fs-2xs); font-weight: 700; text-align: center;
}
#feed div.ministerio { background: var(--yellow); }
#feed div.bom { background: var(--mint, #19c39c); color: #fff; }
#feed div.mau { background: var(--pink, #ff4f9a); color: #fff; }

#medidores {
  min-width: 132px; padding: 7px 10px; border-radius: 12px; border: 2px solid var(--edge);
  background: rgba(255, 253, 245, .86); box-shadow: 0 3px 0 var(--edge);
  font-size: var(--fs-3xs); font-weight: 700; line-height: 1.45; white-space: pre; font-variant-numeric: tabular-nums;
}
#aviso {
  position: absolute; left: 50%; top: calc(max(8px, var(--safe-t)) + 54px); transform: translateX(-50%);
  padding: 8px 14px; border-radius: 12px; border: 2px solid var(--edge); background: var(--yellow);
  font-size: var(--fs-sm); font-weight: 700; box-shadow: 0 3px 0 var(--edge); max-width: 78vw; text-align: center;
}

/* ── controlos de toque ──
   A camada `#toque` apanha os dedos no ecrã TODO: é ela que ouve o joystick e a zona de olhar.
   O desenho do joystick não recebe toque nenhum (era ele que os engolia, e tocar mesmo em cima
   dele não fazia nada); os botões é que param o toque neles. */
#toque { position: absolute; inset: 0; pointer-events: auto; touch-action: none; z-index: 1; }
.tb-btn, #direita, #topo, #molhado { z-index: 3; }
#stick {
  pointer-events: none; position: absolute; left: max(16px, var(--safe-l)); bottom: max(16px, var(--safe-b));
  width: clamp(96px, 24vmin, 150px); aspect-ratio: 1; border-radius: 50%;
  border: 3px solid rgba(23, 21, 59, .5); background: rgba(255, 253, 245, .4); touch-action: none;
}
#stickPeg {
  position: absolute; left: 50%; top: 50%; width: 38%; aspect-ratio: 1; border-radius: 50%;
  transform: translate(-50%, -50%); background: rgba(255, 253, 245, .9); border: 3px solid var(--edge);
}
/* O gatilho da esquerda vive AO LADO do joystick (nunca por cima), para o polegar esquerdo o
   alcançar sem tirar o direito da mira. É a razão de ser deste botão. */
#botoesEsq {
  pointer-events: none; z-index: 2; position: absolute; bottom: max(14px, var(--safe-b));
  left: calc(max(16px, var(--safe-l)) + clamp(96px, 24vmin, 150px) + 12px);
}
#botoes {
  pointer-events: none; z-index: 2; position: absolute; right: max(14px, var(--safe-r)); bottom: max(14px, var(--safe-b));
  width: min(52vw, 260px); display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: flex-end; gap: 8px;
}
.tbtn {
  pointer-events: auto; touch-action: none; z-index: 2; position: relative; width: clamp(48px, 12vmin, 70px); aspect-ratio: 1; border-radius: 50%;
  border: 3px solid var(--edge); background: rgba(255, 253, 245, .85); box-shadow: 0 4px 0 var(--edge);
  font-size: clamp(1.1rem, 4.4vmin, 1.7rem); display: grid; place-items: center; padding: 0;
}
.tbtn.grande { width: clamp(62px, 16vmin, 92px); }
.tbtn.fogo { background: rgba(95, 191, 255, .92); width: clamp(74px, 19vmin, 106px); }
.tbtn.on { background: var(--mint); color: #fff; }

/* ── ecrãs ── */
.screen {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center;
  padding: max(10px, var(--safe-t)) max(10px, var(--safe-r)) max(10px, var(--safe-b)) max(10px, var(--safe-l));
  background: radial-gradient(circle at 50% 30%, #dff1ff 0%, #bfe9ff 60%, #9fd9f7 100%);
}
.card {
  width: min(560px, 94vw); max-height: 96dvh; overflow: auto; overscroll-behavior: contain;
  background: var(--white); border: 3px solid var(--edge); border-radius: var(--radius);
  box-shadow: 0 8px 0 var(--edge); padding: clamp(12px, 3vmin, 24px); text-align: center;
}
.logo { font-size: clamp(30px, 9vmin, 58px); line-height: 1; }
.logo .gota { margin-left: -.15em; }
.card h1 { font: 800 clamp(22px, 6vmin, 38px)/1.05 var(--display); margin: .1em 0 .2em; }
.card h1 em { color: var(--blue); font-style: normal; }
.card h2 { font: 800 clamp(18px, 4.6vmin, 26px)/1.1 var(--display); margin: 0 0 .3em; }
.tag { margin: 0 0 10px; font-size: var(--fs-sm); font-weight: 700; color: var(--muted); }
.small-note { margin: 0 auto 12px; font-size: var(--fs-xs); color: var(--ink-2); max-width: 46ch; }
.lobby-label { display: block; margin: 0 0 4px; font-size: var(--fs-xs); font-weight: 700; color: var(--ink-2); }
.valor { font-size: var(--fs-xs); font-weight: 700; margin: 2px 0 12px; }
input[type=range] { width: min(320px, 82%); accent-color: var(--blue); }
.btn {
  display: inline-block; margin: 4px; padding: 9px 16px; border-radius: 14px; border: 3px solid var(--edge);
  background: var(--white); color: var(--ink); font: 700 var(--fs-md)/1.2 var(--font);
  box-shadow: 0 4px 0 var(--edge); cursor: pointer;
}
.btn.primary { background: var(--blue); color: #fff; }
.btn.grande { display: block; width: min(320px, 86%); margin: 10px auto 6px; padding: 12px 18px; font-size: var(--fs-lg); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--edge); }
.escolhas { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 0 0 10px; }
.chip {
  padding: 7px 12px; border-radius: 12px; border: 3px solid var(--edge); background: var(--white); color: var(--ink);
  font: 700 var(--fs-sm)/1.2 var(--font); box-shadow: 0 3px 0 var(--edge); cursor: pointer; white-space: nowrap;
}
.chip.on { background: var(--blue); color: #fff; }
.chip:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--edge); }

#fimTabela { margin: 6px 0 10px; max-height: 46dvh; overflow: auto; overscroll-behavior: contain; }
#fimTabela table { width: 100%; border-collapse: collapse; font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
#fimTabela th { font-size: var(--fs-3xs); color: var(--muted); font-weight: 700; padding: 0 6px 3px; }
#fimTabela td { padding: 3px 6px; border-top: 2px solid rgba(23, 21, 59, .12); }
#fimTabela td.nome { text-align: left; font-weight: 700; }
#fimTabela td.nome i { font-style: normal; font-size: var(--fs-3xs); color: var(--muted); }
#fimTabela tr.eu td { background: rgba(95, 191, 255, .18); }

.teclas { margin: 10px 0 2px; font-size: var(--fs-2xs); color: var(--muted); line-height: 1.6; }
.teclas b { color: var(--ink); }
.rank-link { display: inline-block; margin-top: 8px; font-size: var(--fs-xs); font-weight: 700; color: var(--blue); }
/* dois lado a lado (ranking + hub): um bocado de ar entre eles, sem crescer em altura */
.rank-link + .rank-link { margin-left: 14px; }

/* ── avisos que mandam no jogo: "clica para jogar" e "roda o telemóvel" ── */
.tapa {
  position: fixed; inset: 0; z-index: 15; display: grid; place-items: center; pointer-events: auto;
  background: rgba(23, 21, 59, .5); padding: 16px; text-align: center; cursor: pointer;
}
.tapa .balao {
  background: var(--white); border: 3px solid var(--edge); border-radius: var(--radius);
  box-shadow: 0 8px 0 var(--edge); padding: clamp(12px, 3vmin, 22px) clamp(16px, 4vmin, 28px);
  max-width: min(460px, 88vw);
}
.tapa .balao b { display: block; font: 800 var(--fs-lg)/1.2 var(--display); margin-bottom: 6px; }
.tapa .balao span { display: block; font-size: var(--fs-xs); color: var(--ink-2); line-height: 1.5; }
.tapa .grandalhao { font-size: clamp(34px, 11vmin, 64px); line-height: 1; margin-bottom: 4px; }
/* quando o browser recusou prender o rato, o aviso encolhe para uma tira que não estorva */
#clica.pequeno { background: none; place-items: start center; pointer-events: none; padding-top: max(56px, calc(var(--safe-t) + 52px)); }
#clica.pequeno .balao { box-shadow: 0 3px 0 var(--edge); padding: 7px 13px; background: var(--yellow); }
#clica.pequeno .balao b { font-size: var(--fs-sm); margin-bottom: 2px; }
#clica.pequeno .balao span { font-size: var(--fs-3xs); }
#clica.pequeno .grandalhao { display: none; }
#rodar { z-index: 16; }

#toasts { position: fixed; left: 50%; bottom: calc(max(10px, var(--safe-b)) + 6px); transform: translateX(-50%); z-index: 30; display: grid; gap: 6px; pointer-events: none; }
#toasts div {
  padding: 7px 13px; border-radius: 12px; border: 2px solid var(--edge); background: var(--white);
  font-size: var(--fs-xs); font-weight: 700; box-shadow: 0 3px 0 var(--edge);
}

/* ecrãs baixinhos (telemóvel deitado): encolhe o cartão em vez de deixar fazer scroll */
/* de que lado está o gatilho (só no telemóvel) */
#toque.so-esq #btTiro, #toque.so-dir #btTiroE { display: none; }

@media (max-height: 460px) {
  .card { padding: 10px 14px; }
  .teclas { display: none; }
  .logo { font-size: clamp(24px, 7vmin, 36px); }
  .small-note { display: none; }
  .btn.grande { margin: 6px auto 2px; padding: 9px 14px; }
  .escolhas { gap: 5px; margin-bottom: 5px; }
  .chip { padding: 4px 9px; }
  .valor { margin-bottom: 5px; }
  .logo { display: none; }
  .card h1 { margin: 0 0 .1em; }
  .tag { margin-bottom: 5px; }
  .lobby-label { margin-bottom: 2px; }
  input[type=range] { margin: 0; }
  .teclas { margin: 5px 0 0; line-height: 1.35; }
  .rank-link { margin-top: 4px; }
  #fimTabela { max-height: 34dvh; }
  #feed { bottom: calc(max(8px, var(--safe-b)) + 6px); max-width: 56vw; }
  #molhado { top: calc(max(6px, var(--safe-t)) + 44px); }
}
/* telemóvel: o rodapé das notícias não pode ir parar por baixo dos botões */
html.touch #feed { bottom: calc(max(10px, var(--safe-b)) + 4px); max-width: 44vw; left: 50%; }
html.touch #placar { display: none; }

/* ───────── FASE 2: menu, salas, lobby, equipas e emotes ─────────
   Regra da casa outra vez: cabe tudo num ecrã, a 360×640 e a 844×390, sem scroll de página e
   sem texto cortado. As listas têm o seu próprio scroll, com altura em dvh. */

/* "Tenho um código": o caminho escondido, pequenino de propósito */
.linkzinho {
  display: block; margin: 6px auto 0; padding: 4px 8px; border: 0; background: none;
  color: var(--muted); font: 700 var(--fs-2xs)/1.3 var(--font); text-decoration: underline; cursor: pointer;
}
#codeBox { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 8px; }
#codeBox input {
  width: 8ch; padding: 8px 10px; border-radius: 12px; border: 3px solid var(--edge); background: var(--white);
  font: 800 var(--fs-lg)/1 var(--display); text-align: center; letter-spacing: .12em; text-transform: uppercase;
}
.linha-bts { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 6px 0; }
.mini-tag { font-size: var(--fs-2xs); font-weight: 700; color: var(--muted); }
.muted { font-size: var(--fs-xs); color: var(--muted); margin: 8px 0; }
/* O recado da sala explica o que falta fazer — esse NUNCA se esconde, nem no telemóvel deitado. */
.hint { margin: 2px 0 6px; font-size: var(--fs-2xs); font-weight: 700; color: var(--ink-2); line-height: 1.35; }

/* ── lista de salas com gente ── */
#roomList {
  display: grid; gap: 6px; margin: 8px 0; max-height: 40dvh; overflow: auto; overscroll-behavior: contain;
}
.room-item {
  display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "c n s" "c m s";
  align-items: center; gap: 2px 10px; width: 100%; text-align: left; padding: 7px 11px;
  border-radius: 14px; border: 3px solid var(--edge); background: var(--white); box-shadow: 0 3px 0 var(--edge);
  cursor: pointer; font-family: var(--font);
}
.room-item:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--edge); }
.room-item .rc { grid-area: c; font: 800 var(--fs-lg)/1 var(--display); color: var(--blue); letter-spacing: .06em; }
.room-item .rn { grid-area: n; font-size: var(--fs-xs); font-weight: 700; }
.room-item .rm { grid-area: m; font-size: var(--fs-3xs); color: var(--muted); }
.room-item .rs { grid-area: s; font-size: var(--fs-2xs); font-weight: 700; white-space: nowrap; text-align: right; }

/* ── a sala à espera ── */
#roomSlots { display: grid; gap: 6px; margin: 6px 0; max-height: 34dvh; overflow: auto; overscroll-behavior: contain; }
#roomSlots.duas { grid-template-columns: 1fr 1fr; align-items: start; }
.slot-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.team-box { display: grid; gap: 5px; padding: 6px; border-radius: 14px; border: 3px solid var(--edge); background: rgba(95, 191, 255, .10); }
.team-box.e1 { background: rgba(255, 79, 154, .10); }
.team-h { font: 800 var(--fs-xs)/1 var(--display); color: var(--ink-2); }
.slot {
  display: grid; gap: 3px; padding: 6px 8px; border-radius: 12px; border: 2px solid var(--edge);
  background: var(--white); text-align: left; min-width: 0;
}
.slot.boneco, .slot.livre { opacity: .65; }
.slot.eu { box-shadow: inset 0 0 0 2px var(--blue); }
.slot-name { display: flex; align-items: center; gap: 5px; min-width: 0; }
.slot-name b { font-size: var(--fs-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot-name .ic { font-size: var(--fs-md); line-height: 1; }
.slot-row { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.slot .tag { font-size: var(--fs-3xs); font-weight: 700; padding: 1px 6px; border-radius: 8px; background: rgba(23, 21, 59, .1); color: var(--ink-2); }
.slot .tag.ok { background: var(--mint, #19c39c); color: #fff; }
.mini {
  padding: 1px 7px; border-radius: 9px; border: 2px solid var(--edge); background: var(--white);
  font: 700 var(--fs-3xs)/1.5 var(--font); cursor: pointer;
}
.mini.kick { background: var(--pink, #ff4f9a); color: #fff; }

/* ── regras da partida ── */
#roomOpts { display: grid; gap: 5px; margin: 4px 0 8px; max-height: 26dvh; overflow: auto; overscroll-behavior: contain; }
.opt { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.opt > span { font-size: var(--fs-2xs); font-weight: 700; color: var(--ink-2); }
.segmented { display: flex; flex-wrap: wrap; gap: 4px; }
.segmented button {
  padding: 4px 9px; border-radius: 10px; border: 2px solid var(--edge); background: var(--white);
  font: 700 var(--fs-3xs)/1.4 var(--font); cursor: pointer; white-space: nowrap;
}
.segmented button.on { background: var(--blue); color: #fff; }
.opt-line { margin: 0; font-size: var(--fs-2xs); color: var(--ink-2); }
.opt-line b { color: var(--ink); }

/* ── marcador das equipas, no topo ── */
#equipas {
  position: absolute; top: calc(max(8px, var(--safe-t)) + 42px); left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 11px;
  border: 2px solid var(--edge); background: rgba(255, 253, 245, .9); box-shadow: 0 3px 0 var(--edge);
  font-variant-numeric: tabular-nums; z-index: 3;
}
#equipas b { font: 800 var(--fs-md)/1 var(--display); }
#equipas b.e0 { color: #3355ff; }
#equipas b.e1 { color: #ff4f9a; }
#equipas b.minha { text-decoration: underline; }
#equipas i { font-size: var(--fs-3xs); font-style: normal; color: var(--muted); }
.fim-equipas { margin: 0 0 6px; font-size: var(--fs-sm); font-weight: 700; }
.fim-equipas .e0 { color: #3355ff; }
.fim-equipas .e1 { color: #ff4f9a; }

/* ── emotes ── */
#btnEmotes { left: auto; right: max(8px, var(--safe-r)); top: auto; bottom: max(8px, var(--safe-b)); pointer-events: auto; z-index: 4; }
html.touch #btnEmotes { right: auto; left: calc(max(8px, var(--safe-l)) + 48px); top: max(8px, var(--safe-t)); bottom: auto; }
/* A tabuleta dos emotes abre ao meio do ecrã: assim nunca tapa o molhado, o placar nem o joystick,
   seja qual for o tamanho. Fecha-se logo que se escolhe um. */
#emotes {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  display: flex; flex-wrap: wrap; justify-content: center; gap: 6px;
  max-width: min(74vw, 320px); padding: 8px; border-radius: 18px; border: 3px solid var(--edge);
  background: rgba(255, 253, 245, .94); box-shadow: 0 5px 0 var(--edge);
  pointer-events: auto; z-index: 6;
}
.tbtn.emote { width: clamp(38px, 9vmin, 50px); font-size: clamp(1rem, 3.6vmin, 1.4rem); box-shadow: 0 3px 0 var(--edge); }
#baloes { position: absolute; inset: 0; pointer-events: none; }
.balao-emote {
  position: absolute; left: 0; top: 0; padding: 3px 9px; border-radius: 12px; border: 2px solid var(--edge);
  background: rgba(255, 253, 245, .95); box-shadow: 0 3px 0 var(--edge); font-size: var(--fs-lg); line-height: 1.2;
  transition: opacity .12s linear; will-change: transform;
}
/* na bancada não há mira nem arma nem molhado: não são teus */
#hud.bancada #mira, #hud.bancada #molhado, #hud.bancada #armaCartao, #hud.bancada #emotes, #hud.bancada #btnEmotes { display: none; }

/* ── ecrãs baixinhos (telemóvel deitado): encolher em vez de cortar ── */
@media (max-height: 460px) {
  #roomList { max-height: 30dvh; }
  #roomSlots { max-height: 24dvh; }
  #roomOpts { max-height: 20dvh; }
  .room-item { padding: 5px 9px; }
  .linkzinho { margin-top: 2px; }
  #codeBox { margin-top: 4px; }
  #equipas { top: calc(max(4px, var(--safe-t)) + 36px); }
}
@media (max-width: 420px) {
  .slot-grid, #roomSlots.duas { grid-template-columns: 1fr; }
  .room-item { grid-template-columns: auto 1fr; grid-template-areas: "c n" "c m" "c s"; }
  .room-item .rs { text-align: left; }
}
