/* nada de zoom por toque duplo/pinça em lugar nenhum (o iPhone ignora user-scalable=no) */
html, body { touch-action: manipulation; -webkit-text-size-adjust: 100%; }
body.touch, body.touch * { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
body.touch input, body.touch textarea { -webkit-user-select: text; user-select: text; }
/* ===== Celular / tablet (body.touch) e telas baixas ===== */
body.touch { -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; overscroll-behavior: none; }
body.touch canvas { touch-action: none; }
/* iOS dá zoom em campos com fonte < 16px: evita (body.touch entra já no começo, ver rotateGate em touch.js) */
body.touch input, body.touch textarea, body.touch select { font-size: 16px !important; -webkit-user-select: text; user-select: text; }

/* ---------- teclado do celular (ui/keyboard.js): html.kb = digitando; --kb-bottom = quanto do fundo o teclado cobre.
   Deitado, o teclado come mais da metade da altura: o campo vira uma barra logo acima dele, o resto some. ---------- */
/* chat: destino · campo · enviar · fechar, presa acima do teclado; o histórico fica pequeno no canto */
body:not(.touch) #chat :is(.ch-send, .ch-x) { display: none; }
html body.touch #chat.typing { z-index: 75; } /* fechado o chat fica por baixo dos controles; digitando, por cima */
html body.touch #chat .ch-form { position: fixed; left: calc(env(safe-area-inset-left, 0px) + 8px); right: calc(env(safe-area-inset-right, 0px) + 8px); bottom: calc(var(--kb-bottom, 0px) + 8px);
  margin: 0; display: flex; align-items: center; gap: 6px; padding: 6px; border: 1px solid rgba(255,255,255,.2); border-radius: var(--r, 6px); background: rgba(12, 14, 19, .96); }
html body.touch #chat .ch-form input { height: 44px; padding: 0 12px; }
html body.touch #chat .ch-scope { min-height: 44px; }
html body.touch #chat :is(.ch-send, .ch-x) { flex: none; width: 44px; height: 44px; display: grid; place-items: center; padding: 0; border: 0; border-radius: var(--r-sm, 4px); color: #fff; }
html body.touch #chat .ch-send { background: var(--side-ui, #cf1f27); }
html body.touch #chat .ch-x { background: transparent; color: var(--text-2, #b6bcc7); }
html body.touch #chat :is(.ch-send, .ch-x) svg { width: 22px; height: 22px; }
/* link do YouTube: digitando, a janela encolhe para campo + prévia + Tocar, logo acima do teclado */
html.kb body.touch #yt-modal { align-items: end; padding: 8px calc(env(safe-area-inset-right, 0px) + 8px) calc(var(--kb-bottom, 0px) + 8px) calc(env(safe-area-inset-left, 0px) + 8px); }
html.kb body.touch #yt-modal .ytm-card { max-height: calc(var(--vv-h, 100vh) - 16px); overflow-y: auto; padding: 10px 12px; border-radius: 12px; }
html.kb body.touch #yt-modal :is(.ytm-head, .ytm-recent, .ytm-keys, .ytm-stop) { display: none; }
html.kb body.touch #yt-modal .ytm-x { top: 6px; right: 6px; }
html.kb body.touch #yt-modal .ytm-field { margin-right: 34px; }
html.kb body.touch #yt-modal .ytm-form { display: flex; flex-direction: column; gap: 8px; }
html.kb body.touch #yt-modal .ytm-actions { order: 1; margin: 0; } /* "Tocar" logo abaixo do campo; a prévia vem depois (rola) */
html.kb body.touch #yt-modal .ytm-preview { order: 2; margin: 0; }
html.kb body.touch #yt-modal .ytm-msg:empty { display: none; }
html.kb body.touch #yt-modal .ytm-preview img { width: 72px; }
/* apelido (menu): só o campo, preso acima do teclado (o miolo do menu tem transform, que prenderia o "fixed" nele) */
html.kb body.touch .menu-main:focus-within { transform: none; animation: none; }
html.kb body.touch .namebox:focus-within { position: fixed; z-index: 90; left: calc(env(safe-area-inset-left, 0px) + 8px); right: calc(env(safe-area-inset-right, 0px) + 8px); bottom: calc(var(--kb-bottom, 0px) + 8px);
  padding: 8px; border: 1px solid var(--line-2); border-radius: var(--r, 6px); background: var(--ink-1); }
html.kb body.touch .namebox:focus-within label { display: none; }
/* chave do admin: o formulário desce para logo acima do teclado, sem o texto de ajuda */
html.kb body.touch .adm-login { align-items: end; padding-bottom: calc(var(--kb-bottom, 0px) + 8px); }
html.kb body.touch .adm-login form { gap: 8px; padding: 10px 14px; }
html.kb body.touch .adm-login b { font-size: 15px; }
html.kb body.touch .adm-login :is(span, em:empty) { display: none; }

/* ---------- camada de controles (enxuta: só ícones, anel de recarga, nada no meio da tela) ---------- */
/* a camada cobre a tela toda (arrastar em qualquer canto gira a câmera), mas os botões ficam fora do entalhe/
   ilha da câmera e da barra de gestos (safe-area; precisa de viewport-fit=cover, já no index.html) */
#touch { --sl: env(safe-area-inset-left, 0px); --sr: env(safe-area-inset-right, 0px); --sb: env(safe-area-inset-bottom, 0px); --st: env(safe-area-inset-top, 0px);
  --glass: rgba(12, 14, 19, .62); --edge: rgba(255, 255, 255, .2);
  position: fixed; inset: 0; z-index: 19; touch-action: none; }
#touch.hidden { display: none; }
/* joystick: parado é só um aro discreto; aparece inteiro onde o dedo encostar */
.t-stick { position: absolute; left: calc(var(--sl) + 92px); top: calc(100% - var(--sb) - 92px); width: 96px; height: 96px; transform: translate(-50%, -50%); border-radius: 50%; pointer-events: none;
  border: 1.5px solid rgba(255,255,255,.28); background: rgba(12, 14, 19, .12); opacity: .7; transition: opacity .15s; }
.t-stick.active { opacity: 1; background: rgba(12, 14, 19, .3); border-color: rgba(255,255,255,.45); transition: none; }
#touch:not(.driving):not(.riding) .t-stick.run { border-color: rgba(255,255,255,.9); } /* a pé, joystick na borda = correndo */
.t-stick i { position: absolute; left: 50%; top: 50%; width: 40px; height: 40px; margin: -20px; border-radius: 50%; background: rgba(255,255,255,.3); transition: background .15s; }
.t-stick.active i { background: rgba(255,255,255,.9); transition: none; }

.t-pad { position: absolute; right: var(--sr); bottom: var(--sb); width: 260px; height: 260px; pointer-events: none; }
#touch.driving .t-pad.walk, #touch:not(.driving) .t-pad.car { display: none; }
.t-btn { --f: 1; position: absolute; pointer-events: auto; touch-action: none; width: 52px; height: 52px; padding: 0; border-radius: 50%; color: #fff; display: grid; place-items: center; font: inherit;
  border: 1.5px solid var(--edge); background: var(--glass); transition: transform .08s, border-color .2s, background .2s; }
.t-btn .ic { width: 50%; height: 50%; display: grid; place-items: center; pointer-events: none; transition: opacity .2s; }
.t-btn .ic svg { width: 100%; height: 100%; }
.t-btn .ic b { font-size: 24px; line-height: 1; font-weight: 900; }
/* sem rótulos: só o botão de usar (dirigir/patinete/carona/descer) e o "Pôr música" do NEUTRO dizem o que fazem */
.t-btn small { display: none; position: absolute; top: calc(100% + 3px); left: 50%; transform: translateX(-50%); white-space: nowrap; font: 700 11px/1 var(--display); letter-spacing: .08em; text-transform: uppercase; text-shadow: 0 1px 3px #000; pointer-events: none; }
.t-use small, .t-yt.hot small { display: block; }
.t-btn .cd { position: absolute; inset: 0; z-index: 2; display: grid; place-items: center; font: 800 18px/1 var(--display); text-shadow: 0 1px 3px #000; pointer-events: none; }
.t-btn.on { transform: scale(.92); background: rgba(40, 45, 55, .9); }
.t-btn.gone { display: none; }
/* armas (coco + habilidades): anel de recarga que vai se fechando; recarregando, o ícone apaga e mostra os segundos */
.t-btn.t-ab::after { content: ''; position: absolute; inset: -1.5px; border-radius: 50%; pointer-events: none;
  background: conic-gradient(var(--ring, #fff) calc(var(--f) * 360deg), transparent 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 3px)); mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 3px)); }
.t-btn.t-ab.ready::after { display: none; }
.t-btn.t-ab:not(.ready) .ic { opacity: .35; }
.t-btn.t-ab.ready { border-color: rgba(255,255,255,.55); }
/* a pé: coco grande no canto, habilidades num arco em volta, ao alcance do polegar direito */
.t-fire { right: 20px; bottom: 22px; width: 76px; height: 76px; background: color-mix(in srgb, var(--mine) 72%, #000); }
.t-fire.t-ab.ready { border-color: rgba(255,255,255,.7); }
.t-fire .ic { width: 54%; height: 54%; }
.t-dash { right: 124px; bottom: 34px; }
.t-balao { right: 97px; bottom: 99px; }
.t-megafone { right: 32px; bottom: 126px; }
.t-santinhos { --ring: var(--gold); right: 180px; bottom: 102px; width: 56px; height: 56px; }
.t-santinhos.ready { border-color: var(--gold); color: var(--gold); }
/* usar (dirigir / carona / patinete): verde e pulsando quando aparece; descer: vermelho como o "sair" do carro */
.t-use { right: 82px; bottom: 177px; width: 56px; height: 56px; border-color: #fff; background: #1f8a4c; animation: t-pulse 1.4s infinite; }
.t-use.off { background: #b3261e; border-color: rgba(255,255,255,.5); animation: none; }
@keyframes t-pulse { 50% { box-shadow: 0 0 0 5px rgba(47,191,113,.3); } }
/* no patinete: mãos no guidão (sem coco nem habilidades) — sobra só "descer", grande no lugar do coco */
#touch.riding .t-pad.walk .t-btn:not(.t-use) { display: none; }
#touch.riding .t-use { right: 20px; bottom: 22px; width: 70px; height: 70px; }
/* de carona: dá para jogar coco, mas não usar habilidade */
#touch.passenger :is(.t-dash, .t-balao, .t-megafone, .t-santinhos) { display: none; }
/* no carro: sair grande no canto; YouTube, câmera, música e volume em volta, só ícones */
.t-exit { right: 20px; bottom: 22px; width: 70px; height: 70px; border-color: rgba(255,255,255,.5); background: #b3261e; }
.t-yt { right: 108px; bottom: 30px; }
.t-center { right: 178px; bottom: 34px; width: 46px; height: 46px; }
.t-prev { right: 104px; bottom: 100px; width: 46px; height: 46px; }
.t-next { right: 36px; bottom: 112px; width: 46px; height: 46px; }
.t-voldown { right: 104px; bottom: 162px; width: 46px; height: 46px; }
.t-volup { right: 36px; bottom: 174px; width: 46px; height: 46px; }
/* motorista NEUTRO: Q/E não trocam música — some a troca; sem link tocando, o YouTube cresce e pulsa ("Pôr música") */
#touch.quiet :is(.t-prev, .t-next) { display: none; }
.t-yt.hot { right: 100px; bottom: 34px; width: 62px; height: 62px; border-color: #fff; animation: t-pulse 1.4s infinite; }
/* canto de cima à direita: chat, microfone (um toque liga/desliga) e menu "⋯" com o resto; o menu desce como uma lista
   curta, alinhada pela direita (o HUD usa o canto esquerdo e o meio de cima; engrenagem e som dele somem no toque) */
.t-quick { position: absolute; z-index: 5; right: calc(var(--sr) + 8px); top: calc(var(--st) + 8px); display: flex; gap: 8px; } /* acima dos números de recarga */
.t-quick .t-btn { position: relative; width: 44px; height: 44px; }
.t-quick .t-btn .ic { width: 22px; height: 22px; }
.t-quick .t-btn.live { border-color: #4fd17d; color: #4fd17d; background: rgba(18, 58, 34, .85); } /* microfone ligado */
.t-quick .t-btn.muted { color: rgba(255,255,255,.55); }
.t-quick .t-btn.live.talk { box-shadow: 0 0 0 4px rgba(79,209,125,.4); } /* falando agora */
#touch.menu .t-more { background: rgba(40, 45, 55, .92); border-color: rgba(255,255,255,.5); }
.t-menu { display: none; position: absolute; right: 0; top: calc(100% + 8px); min-width: 168px; padding: 6px; flex-direction: column; gap: 2px;
  background: rgba(12, 14, 19, .97); border: 1px solid var(--edge); border-radius: var(--r, 6px); }
#touch.menu .t-menu { display: flex; }
.t-menu .t-chatm { display: none; }
/* tela estreita: o canto fica só com microfone + "⋯" (o chat vai para o menu) e não encosta na faixa do placar */
@media (max-width: 700px) {
  .t-quick > .t-chat { display: none; }
  .t-menu .t-chatm { display: flex; }
}
.t-item { pointer-events: auto; display: flex; align-items: center; gap: 12px; min-height: 42px; padding: 0 12px; border: 0; border-radius: var(--r-sm, 4px); background: transparent; color: var(--text, #fff);
  font: 700 15px/1 var(--display); letter-spacing: .06em; text-transform: uppercase; text-align: left; }
.t-item .ic { width: 20px; height: 20px; display: grid; place-items: center; pointer-events: none; color: var(--text-2, #b6bcc7); }
.t-item .ic svg { width: 100%; height: 100%; }
.t-item.on { background: rgba(255,255,255,.1); }

/* ---------- celular em pé: "Gire o celular" por cima de tudo (só celular: tela estreita em retrato) ---------- */
#rotate-gate { display: none; }
@media (orientation: portrait) and (max-width: 600px) {
  #rotate-gate { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 24px; background: var(--ink-0); color: var(--text); text-align: center; touch-action: none; }
}
.rg-box { display: flex; flex-direction: column; align-items: center; max-width: 300px; }
.rg-box svg { width: 96px; height: 96px; margin-bottom: 18px; color: var(--text); }
.rg-dev { transform-box: fill-box; transform-origin: center; animation: rg-turn 2.6s var(--ease) infinite; }
@keyframes rg-turn { 0%, 18% { transform: none; } 50%, 82% { transform: rotate(-90deg); } 100% { transform: none; } }
@media (prefers-reduced-motion: reduce) { .rg-dev { animation: none; transform: rotate(-90deg); } }
.rg-box h2 { margin: 0; font: 800 italic 30px/1.05 var(--display); letter-spacing: .01em; text-transform: uppercase; text-wrap: balance; }
.rg-box p { margin: 10px 0 0; font: 500 15px/1.45 var(--font); color: var(--text-2); }
.rg-go { margin-top: 24px; min-height: 48px; padding: 0 22px; border: 0; border-radius: var(--r-sm); background: var(--side-ui); color: #fff;
  font: 700 16px/1 var(--display); letter-spacing: .08em; text-transform: uppercase; }
.rg-go:active { transform: translateY(1px); }
.rg-stripe { position: absolute; left: 0; right: 0; bottom: 0; height: 6px; background: linear-gradient(90deg, var(--lula) 0 50%, var(--flavio) 50% 100%); }

/* crédito do mapa: abaixo da camada de toque (não rouba o joystick) e fora do entalhe. O resto do HUD no toque
   (tamanhos, posições, safe-area) e o menu em telas baixas ficam em hud.css / hud-pro.css / style.css / creator.css. */
body.touch #attrib { z-index: 18; left: calc(env(safe-area-inset-left, 0px) + 8px); bottom: calc(env(safe-area-inset-bottom, 0px) + 3px); }

/* ---------- janela estreita (computador; celular em pé fica atrás do #rotate-gate): menu em uma coluna ---------- */
@media (max-width: 560px) {
  .menu-top { flex-direction: row !important; justify-content: center; flex-wrap: wrap; }
  .menu-top .brand-chip { display: none; }
  .menu-actions { justify-content: center; }
  .tagline { font-size: 14px; }
  .side { grid-template-columns: 1fr; justify-items: start; padding: 12px; }
  .side p { display: none; }
  .side .emblem-slot { grid-row: auto; width: 40px; height: 40px; margin-bottom: 6px; }
  .side h2 { font-size: 26px; }
}
