:root {
  --bg: #191708;                       /* amarelo-sujo escuro (Backrooms) */
  --ui: rgba(255, 255, 255, 0.92);
  --ui-dim: rgba(255, 255, 255, 0.55);
  --panel: rgba(26, 24, 10, 0.74);
  --accent: #cde05a;                   /* verde-fluorescente doentio */
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; background: var(--bg); }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ui);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

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

/* ---------- Vinheta de feedback ---------- */
#vignette {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
  box-shadow: inset 0 0 120px 30px rgba(255, 40, 40, 0.0);
}
#vignette.danger {
  opacity: 1;
  box-shadow: inset 0 0 140px 40px rgba(255, 40, 40, 0.55);
  animation: vignettePulse 0.7s ease-in-out infinite;
}
#vignette.almost {
  opacity: 1;
  box-shadow: inset 0 0 130px 36px rgba(70, 230, 176, 0.5);
  animation: vignettePulse 1s ease-in-out infinite;
}
/* Detecção (visto, mas captura ainda não iminente): vermelho mais leve e rápido. */
#vignette.spotted {
  opacity: 1;
  box-shadow: inset 0 0 110px 26px rgba(255, 70, 50, 0.34);
  animation: vignettePulse 0.42s ease-in-out infinite;
}
@keyframes vignettePulse {
  0%, 100% { filter: brightness(0.7); }
  50% { filter: brightness(1.25); }
}

/* ---------- Alerta de detecção (ícone de exclamação) ---------- */
#alert {
  position: absolute;
  top: max(64px, calc(env(safe-area-inset-top) + 56px));
  left: 50%;
  transform: translate(-50%, -6px) scale(0.85);
  z-index: 8;
  pointer-events: none;
  opacity: 0;
  transition: transform 0.12s ease; /* opacity instantânea: alerta aparece na hora */
}
#alert.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
#alert span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px; height: 46px;
  border-radius: 50%;
  font-size: 28px;
  font-weight: 900;
  color: #fff;
  background: rgba(224, 40, 30, 0.92);
  border: 2px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 4px 20px rgba(255, 40, 30, 0.55);
  animation: alertBounce 0.5s ease-in-out infinite;
}
@keyframes alertBounce {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-4px) scale(1.08); }
}

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 0; right: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  /* Respeita entalhes laterais (landscape com notch): o placar à direita não
     encosta na câmera/quina da tela. */
  padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  pointer-events: none;
  z-index: 5;
}
#state-badge {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(6px);
}
#state-badge.latched { color: #0b0e13; background: #e0a94a; border-color: #e0a94a; }
#state-badge.mismatch { color: #fff; background: #c94b55; border-color: #f07a82; }
#state-badge.camo { color: #0b0e13; background: var(--accent); border-color: var(--accent); }

/* Penumbra: aparece quando o jogador está numa zona escura (o Caçador te enxerga
   de mais perto). Feedback essencial — senão a mecânica lê como bug. */

#color-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ui-dim);
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(6px);
}
#color-chip span {
  width: 14px; height: 14px;
  border-radius: 4px;
  background: #8a8f98;
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.5);
}

.water-ammo-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 800;
  color: #59c1e8;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(14, 30, 48, 0.75);
  border: 1.5px solid rgba(89, 193, 232, 0.4);
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.water-ammo-badge.empty {
  color: #ff4a5a;
  border-color: rgba(255, 74, 90, 0.6);
  background: rgba(48, 14, 20, 0.85);
  animation: alertBounce 0.4s ease infinite;
}
.water-ammo-badge .ammo-ic {
  font-size: 15px;
}

.ammo-cfg-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(255, 255, 255, 0.05);
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 12px;
}
.ammo-cfg-panel label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ui);
  display: flex;
  align-items: center;
  gap: 6px;
}
.ammo-cfg-panel select {
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  outline: none;
}
.ammo-cfg-panel .toggle-lbl {
  cursor: pointer;
}
/* Placar da partida (canto superior direito) */
#timer {
  margin-left: auto;
  min-width: 148px;
  padding: 7px 12px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(6px);
  font-variant-numeric: tabular-nums;
}
#timer .t-top,
#timer .t-bottom {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 12px;
}
#timer .t-top { justify-content: space-between; margin-bottom: 5px; }
.t-stage { font-weight: 700; letter-spacing: 0.06em; font-size: 11px; color: var(--ui-dim); }
.t-stage b { color: var(--ui); }
#timer-camo { color: var(--accent); font-weight: 600; }
#timer .t-bar {
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}
#timer-fill {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #ffca3a, var(--accent));
  transition: width 0.2s linear;
}
#timer .t-bottom { margin-top: 5px; color: var(--ui); }
#timer-elapsed { font-weight: 700; }
.t-sep, #timer-goal { color: var(--ui-dim); }
.t-cap { margin-left: auto; font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ui-dim); }

/* Dica: rodapé central, some no mobile estreito */
#hint {
  position: absolute;
  left: 50%;
  bottom: max(12px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(560px, 72vw);
  font-size: 11px;
  color: var(--ui-dim);
  text-align: center;
  line-height: 1.35;
  pointer-events: none;
  z-index: 5;
}
@media (max-width: 720px) {
  #hint {
    display: block;
    bottom: max(88px, calc(env(safe-area-inset-bottom) + 76px));
    width: min(54vw, 340px);
    font-size: 10px;
  }
}

.tutorial { position: fixed; inset: 0; display: flex; align-items: flex-end; justify-content: center; padding: 0 18px 92px; background: rgba(4, 8, 14, 0.16); z-index: 12; pointer-events: auto; }
.tutorial.hidden { display: none; }
.tutorial-card { width: min(420px, 92vw); padding: 18px 20px 16px; border: 1px solid rgba(255,255,255,.22); border-radius: 18px; background: rgba(15, 24, 35, .92); box-shadow: 0 12px 38px rgba(0,0,0,.35); backdrop-filter: blur(12px); }
.tutorial-kicker { color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: .12em; }
.tutorial-card p { margin: 8px 0 16px; color: var(--ui); font-size: 14px; line-height: 1.4; }
.tutorial-actions { display: flex; justify-content: flex-end; gap: 9px; }
.room-code-field { display: none; align-items: center; gap: 8px; margin: 12px auto 0; width: min(280px, 86vw); color: var(--ui-dim); font-size: 11px; }
.room-code-field input { flex: 1; min-width: 0; padding: 8px 10px; border-radius: 9px; border: 1px solid rgba(255,255,255,.2); background: rgba(0,0,0,.3); color: var(--ui); font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
body:has(#screen-mode.active) .room-code-field { display: flex; }

/* ---------- Joystick ---------- */
/* A zona de toque recua da borda pela safe-area (mín. 8px) para não roubar o
   gesto de "voltar" do sistema (Android/iOS) na quina inferior-esquerda. A base
   é `position: fixed` para mapear clientX/clientY direto ao viewport,
   independente desse recuo da zona. */
#joystick-zone {
  position: absolute;
  left: max(8px, env(safe-area-inset-left));
  bottom: max(8px, env(safe-area-inset-bottom));
  width: 45%;
  height: 60%;
  z-index: 6;
  touch-action: none;
}
#joystick-base {
  position: fixed;
  width: 128px; height: 128px;
  margin-left: -64px; margin-top: -64px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 1.5px solid rgba(255, 255, 255, 0.18);
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
}
#joystick-base.active { opacity: 1; }
#joystick-knob {
  position: absolute;
  left: 50%; top: 50%;
  width: 58px; height: 58px;
  margin-left: -29px; margin-top: -29px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.4);
}

/* ---------- Área de olhar (câmera) — espelha o joystick, do outro lado ---------- */
#look-zone {
  position: absolute;
  right: max(8px, env(safe-area-inset-right));
  bottom: max(8px, env(safe-area-inset-bottom));
  width: 45%;
  height: 60%;
  z-index: 6;
  touch-action: none;
}

/* Pincel Livre por UV (Fase 5) — ligado enquanto o painel está aberto (ver
   Game.js:_setupPaintPanel, disparado pelo clique em #btn-brush). Joystick/
   look-zone somem: o dedo precisa chegar direto no canvas pra tocar no
   próprio personagem, sem competir com os controles normais. */
body.painting-active #joystick-zone,
body.painting-active #look-zone {
  display: none;
}

/* ---------- Painel do Pincel Livre (Fase 5) ---------- */
#paint-debug-panel {
  display: none;
  position: fixed;
  left: max(10px, env(safe-area-inset-left));
  top: 50%;
  transform: translateY(-50%);
  z-index: 12;
  width: min(220px, 42vw);
  padding: 12px;
  border-radius: 20px;
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  color: #eef0f2;
  font-size: 11px;
}
body.painting-active #paint-debug-panel { display: block; }

.pdp-title {
  font-weight: 800; font-size: 12px; margin-bottom: 8px;
  display: flex; align-items: center; justify-content: space-between;
}
.pdp-close {
  font: inherit; font-size: 13px; line-height: 1;
  width: 22px; height: 22px; border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
  color: #fff; cursor: pointer;
}
.pdp-close:active { background: rgba(255, 255, 255, 0.25); }
.pdp-size-row {
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 10px;
  color: rgba(255, 255, 255, 0.8);
}
.pdp-size-row input[type="range"] { flex: 1; }
#pdp-size-val { min-width: 34px; text-align: right; font-variant-numeric: tabular-nums; }

.pdp-swatches { display: flex; gap: 6px; margin-bottom: 10px; }
.pdp-swatch {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  cursor: pointer;
}
.pdp-swatch.on { border-color: #fff; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3); }

.pdp-history-row { margin-bottom: 10px; }
.pdp-history-row > span { display: block; color: rgba(255, 255, 255, 0.6); margin-bottom: 4px; }
.pdp-history { display: flex; gap: 6px; min-height: 22px; }
.pdp-history .pdp-swatch { width: 22px; height: 22px; cursor: pointer; }

.pdp-actions { display: flex; flex-direction: column; gap: 6px; }
.pdp-btn {
  font: inherit;
  padding: 7px 8px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
  text-align: left;
}
.pdp-btn.active { background: rgba(159, 232, 255, 0.25); border-color: rgba(159, 232, 255, 0.7); }
.pdp-btn:active { transform: scale(0.97); }

/* ---------- Botões de ação (coluna à direita, acima da área de olhar) ---------- */
/* ---------- Botões de ação mobile em Arco Ergonômico Glassmorphism ---------- */
#actions {
  position: absolute;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  width: 220px;
  height: 220px;
  z-index: 7;
  pointer-events: none; /* só os botões capturam toque */
}

.glass-btn {
  position: absolute;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  user-select: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  border: 1.5px solid rgba(255, 255, 255, 0.42);
  -webkit-backdrop-filter: blur(8px) saturate(180%);
  backdrop-filter: blur(8px) saturate(180%);
  color: #ffffff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font: inherit;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28), inset 0 0 10px rgba(255, 255, 255, 0.15);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
  transition: transform 0.12s cubic-bezier(0.175, 0.885, 0.32, 1.275),
              background 0.15s ease,
              border-color 0.15s ease,
              opacity 0.2s ease;
}

.glass-btn .ic { font-size: 24px; line-height: 1; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4)); }
.glass-btn .lbl { font-size: 10px; font-weight: 700; letter-spacing: 0.03em; opacity: 0.95; margin-top: 2px; }

.glass-btn:active, .glass-btn.active {
  transform: scale(0.93) !important;
  background: rgba(255, 255, 255, 0.32);
  border-color: rgba(255, 255, 255, 0.85);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3), inset 0 0 16px rgba(255, 255, 255, 0.45);
}

/* Posições no Arco Ergonômico */
.action-jump {
  width: 68px; height: 68px;
  right: 10px; bottom: 10px;
  background: rgba(46, 204, 113, 0.22);
  border-color: rgba(46, 204, 113, 0.55);
}
.action-climb {
  width: 58px; height: 58px;
  right: 85px; bottom: 25px;
  opacity: 0.45;
  background: rgba(230, 126, 34, 0.2);
  border-color: rgba(230, 126, 34, 0.5);
}
.action-climb.near {
  opacity: 1;
  transform: scale(1.08);
  border-color: #f39c12;
  box-shadow: 0 0 20px rgba(243, 156, 18, 0.6);
}
.action-pose {
  width: 68px; height: 68px;
  right: 15px; bottom: 95px;
  background: rgba(155, 89, 182, 0.22);
  border-color: rgba(155, 89, 182, 0.55);
}
.action-paint {
  width: 72px; height: 72px;
  right: 90px; bottom: 110px;
  background: rgba(231, 76, 60, 0.25);
  border-color: rgba(231, 76, 60, 0.6);
}

/* ---------- Modo Caçador jogável ----------
   btn-fire ocupa o mesmo lugar/estilo de btn-paint (herda .action-paint); os
   dois nunca aparecem juntos, então não precisam de posição própria. */
#water-ammo-hud,
#btn-fire,
#targets-hud { display: none; }
body.mode-hunter #water-ammo-hud { display: flex; }
body.mode-hunter #btn-fire { display: flex; }
body.mode-hunter #btn-paint,
body.mode-hunter #btn-pose { display: none; }
body.mode-hunter #targets-hud { display: flex; }
body.mode-hunter .stat-camo { display: none; }
body.mode-hunter #color-chip { display: none; }

/* Cooldown do disparo (normal ou penalidade de erro — Fase 2) ou do Scanner (Fase 3):
   esmaece o botão, sem travar o toque (o gate real é _nextFireAt/_scannerCooldown em
   Game.js). */
.glass-btn.cooling { opacity: 0.45; }

/* ---------- Scanner do Caçador (Fase 3) ---------- */
#btn-scan { display: none; }
body.mode-hunter #btn-scan { display: flex; }
#scanner-hud-badge { display: none; }
body.mode-hunter #scanner-hud-badge { display: flex; }

/* ---------- Modo Online (docs/PLANO_MULTIPLAYER.md) ----------
   Sem alvos-boneco (o Camaleão é um jogador de verdade) — munição e Scanner têm
   paridade com o Caçador solo (munição é autoritativa no servidor; Scanner é só
   uma affordance de UI, sem contraparte no servidor — ver Game.js:_updateScanner). */
body.mode-online #water-ammo-hud { display: none; }
body.mode-online.online-hunter #water-ammo-hud { display: flex; }
body.mode-online.online-hunter #btn-fire { display: flex; }
body.mode-online.online-hunter #btn-paint,
body.mode-online.online-hunter #btn-pose { display: none; }
body.mode-online.online-hunter #btn-scan { display: flex; }
body.mode-online.online-hunter #scanner-hud-badge { display: flex; }
/* Lobby maior (docs/PLANO_LOBBY_MULTIPLAYER.md §3.4): reaproveita o mesmo badge 🎯 do
   Caçador solo (#targets-hud) pra mostrar quantos Camaleões de verdade restam. */
body.mode-online.online-hunter #targets-hud { display: flex; }

/* #hint some em telas estreitas (@media acima) — mas no online ele é a ÚNICA forma de
   avisar "você está sozinho na sala" (ver Game._updateOnlineHint()), e celular é
   EXATAMENTE a tela estreita. Mais específico que a regra do media query, então
   sobrepõe independente da ordem no arquivo. */
body.mode-online #hint { display: block; }

/* Vinheta azulada enquanto o pulso está ativo (docs/MECANICA_CACADOR_VISAO.md §3) —
   mesmo padrão de #vignette.danger/.almost/.spotted, cor fria em vez de quente. */
#vignette.scanning {
  opacity: 1;
  box-shadow: inset 0 0 150px 46px rgba(64, 156, 232, 0.5);
  animation: vignettePulse 0.9s ease-in-out infinite;
}

/* Mini-radar: mostra a direção/distância dos alvos vivos em alcance enquanto o Scanner
   está ativo. "Você" fica sempre no centro, alvos aparecem como pontos ao redor. */
#scanner-radar {
  position: absolute;
  top: max(78px, calc(env(safe-area-inset-top) + 70px));
  left: 50%;
  transform: translateX(-50%) scale(0.85);
  width: 96px; height: 96px;
  border-radius: 50%;
  background: rgba(10, 26, 42, 0.55);
  border: 1.5px solid rgba(89, 193, 232, 0.55);
  box-shadow: 0 0 24px rgba(89, 193, 232, 0.35);
  backdrop-filter: blur(6px);
  z-index: 6;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
#scanner-radar.active { opacity: 1; transform: translateX(-50%) scale(1); }
#scanner-you {
  position: absolute;
  left: 50%; top: 50%;
  width: 8px; height: 8px;
  margin: -4px 0 0 -4px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.85);
}
.scanner-dot {
  position: absolute;
  width: 9px; height: 9px;
  margin: -4.5px 0 0 -4.5px;
  border-radius: 50%;
  background: #59c1e8;
  box-shadow: 0 0 8px rgba(89, 193, 232, 0.9);
  animation: scannerBlip 0.6s ease-in-out infinite;
}
@keyframes scannerBlip {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.35); opacity: 0.7; }
}

/* ---------- Menus Radiais Glassmorphic (Poses & Pintura) ---------- */
.radial-menu {
  position: absolute;
  right: 110px;
  bottom: 110px;
  width: 240px;
  height: 240px;
  margin-right: -120px;
  margin-bottom: -120px;
  z-index: 15;
  pointer-events: auto;
  transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.radial-menu.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.7);
}
.radial-center {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 70px; height: 70px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.85);
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 25px rgba(0, 0, 0, 0.5);
}
/* #btn-brush (Fase 5): o centro do menu de pintura é um <button> de verdade
   (o de poses continua sendo um <div>, só decorativo) — reset dos estilos
   nativos de <button> + feedback de toque, mantendo o visual idêntico. */
button.radial-center {
  font: inherit;
  padding: 0;
  margin: 0;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}
button.radial-center:active,
button.radial-center.active {
  background: rgba(46, 196, 182, 0.35);
  border-color: rgba(46, 196, 182, 0.9);
  transform: translate(-50%, -50%) scale(0.94);
}
.radial-title {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--accent);
}
.radial-item {
  position: absolute;
  left: 50%; top: 50%;
  width: 52px; height: 52px;
  margin-left: -26px; margin-top: -26px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  border: 1.5px solid rgba(255, 255, 255, 0.4);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  /* Posicionamento radial em anel */
  --angle: calc(var(--i) * 60deg);
  --r: 92px;
  transform: translate(calc(cos(var(--angle)) * var(--r)), calc(sin(var(--angle)) * var(--r)));
  transition: transform 0.15s ease, background 0.15s ease;
}
.radial-item:active, .radial-item.on {
  background: rgba(255, 255, 255, 0.4);
  border-color: #fff;
  transform: translate(calc(cos(var(--angle)) * var(--r)), calc(sin(var(--angle)) * var(--r))) scale(1.15);
}
.radial-item .r-ic { font-size: 18px; line-height: 1; }
.radial-item .r-label { font-size: 8px; font-weight: 700; margin-top: 1px; }

/* Menu de Pintura Avançada */
.paint-menu {
  width: 220px; height: 160px;
  margin-right: -110px; margin-bottom: -80px;
  border-radius: 20px;
  background: rgba(15, 23, 42, 0.85);
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
.paint-history-ring { display: flex; flex-direction: column; gap: 4px; }
.p-hist-label { font-size: 10px; font-weight: 700; color: var(--ui-dim); text-transform: uppercase; letter-spacing: 0.05em; }
.p-chips { display: flex; gap: 8px; justify-content: center; }
.p-chip {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.6);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  transition: transform 0.1s ease, border-color 0.1s ease;
}
.p-chip:active { transform: scale(1.15); border-color: #fff; }
.paint-finish-toggle { display: flex; gap: 6px; background: rgba(255, 255, 255, 0.1); padding: 3px; border-radius: 10px; }
.finish-btn {
  flex: 1; border: none; background: transparent; color: var(--ui-dim);
  font-size: 11px; font-weight: 700; padding: 6px 0; border-radius: 8px; cursor: pointer;
}
.finish-btn.active { background: rgba(255, 255, 255, 0.25); color: #fff; }

/* ---------- Overlays ---------- */
#start-overlay, #rotate-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: radial-gradient(120% 120% at 50% 30%, #131a25 0%, #070a0f 100%);
}
/* Flex + overflow + margin:auto no cartão: centraliza quando cabe e ROLA
   (sem cortar topo/rodapé) em telas landscape muito baixas. */
#start-overlay {
  display: flex;
  overflow-y: auto;
  padding: 16px;
}
#start-overlay .panel { margin: auto; }
#start-overlay.hidden { display: none; }

.panel { text-align: center; padding: 24px; }
.panel h1 { font-size: 30px; letter-spacing: 0.02em; margin-bottom: 6px; }
.panel p { color: var(--ui-dim); margin-bottom: 22px; font-size: 14px; }
.panel small { display: block; margin-top: 14px; color: var(--ui-dim); font-size: 12px; }

/* Menu inicial: cartão com instruções */
.panel.menu { max-width: 440px; }
.panel.menu h1 {
  font-size: 34px;
  color: var(--accent);
  text-shadow: 0 2px 26px rgba(70, 230, 176, 0.35);
}
.how {
  list-style: none;
  text-align: left;
  margin: 4px auto 22px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: grid;
  gap: 10px;
}
.how li { font-size: 13px; line-height: 1.4; color: var(--ui); display: flex; gap: 10px; align-items: baseline; }
.how li b { color: var(--accent); font-weight: 700; }
.how-ic { font-size: 16px; width: 22px; text-align: center; flex: none; }
#start-btn {
  font: inherit;
  font-weight: 700;
  color: #0b0e13;
  background: var(--accent);
  border: none;
  padding: 14px 28px;
  border-radius: 12px;
  cursor: pointer;
}
#start-btn:active { transform: translateY(1px); }

/* ---------- Game Over ---------- */
#gameover {
  position: absolute;
  inset: 0;
  z-index: 15;
  display: none;
  overflow-y: auto;
  padding: 16px;
  background: rgba(8, 4, 6, 0.72);
  backdrop-filter: blur(3px);
}
#gameover.show { display: flex; }
.go-panel { text-align: center; padding: 24px; margin: auto; }
.go-panel h2 {
  font-size: 44px;
  letter-spacing: 0.14em;
  color: #ff5a4d;
  text-shadow: 0 2px 24px rgba(255, 60, 40, 0.5);
}
.go-panel p { color: var(--ui-dim); margin: 8px 0 22px; }
.go-actions, .win-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}
.btn-primary {
  font: inherit;
  font-weight: 700;
  color: #ffffff;
  background: #2ecc71;
  border: none;
  padding: 12px 22px;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(46, 204, 113, 0.4);
  transition: transform 0.1s ease, filter 0.1s ease;
}
.btn-primary:active { transform: scale(0.96); filter: brightness(1.1); }

.btn-ghost {
  font: inherit;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.85);
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 12px 22px;
  border-radius: 12px;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: transform 0.1s ease, background 0.1s ease;
}
.btn-ghost:active { transform: scale(0.96); background: rgba(255, 255, 255, 0.25); }

/* ---------- Vitória / Fase Concluída ---------- */
#victory {
  position: absolute;
  inset: 0;
  z-index: 15;
  display: none;
  overflow-y: auto;
  padding: 16px;
  background: rgba(4, 12, 9, 0.74);
  backdrop-filter: blur(3px);
}
#victory.show { display: flex; }
.win-panel { text-align: center; padding: 24px; max-width: 460px; margin: auto; }
.win-panel h2 {
  font-size: 40px;
  letter-spacing: 0.12em;
  color: var(--accent);
  text-shadow: 0 2px 24px rgba(70, 230, 176, 0.45);
}
.win-panel p { color: var(--ui-dim); margin: 8px 0 20px; }
.win-stats {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-bottom: 22px;
}
.win-stats .stat {
  flex: 1;
  padding: 12px 8px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.win-stats .stat span {
  display: block;
  font-size: 24px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--ui);
}
.win-stats .stat small {
  display: block;
  margin-top: 4px;
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ui-dim);
}
.win-actions { display: flex; gap: 12px; justify-content: center; }
.win-actions button {
  font: inherit;
  font-weight: 700;
  border: none;
  padding: 12px 22px;
  border-radius: 12px;
  cursor: pointer;
}
.win-actions button:active { transform: translateY(1px); }
.btn-primary { color: #0b0e13; background: var(--accent); }
.btn-ghost {
  color: var(--ui);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18) !important;
}

/* Aviso de rotação: só aparece em retrato (ícone empilhado acima do texto) */
#rotate-overlay {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
}
.rotate-icon { font-size: 44px; margin-bottom: 12px; animation: spin 2.4s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (orientation: portrait) and (max-width: 900px) {
  #rotate-overlay { display: flex; }
}

/* ---------- Compactação para landscape de baixa altura (celular) ----------
   Em telas ~<=480px de altura os cartões de menu/vitória são altos demais;
   reduzimos tipografia e espaçamentos para caberem sem rolar. O scroll dos
   overlays continua como rede de segurança para telas ainda menores. */
@media (max-height: 480px) {
  .panel { padding: 14px; }
  .panel.menu h1 { font-size: 24px; }
  .panel h1 { font-size: 22px; }
  .panel p { margin-bottom: 12px; font-size: 13px; }
  .panel small { margin-top: 10px; }
  .how { gap: 6px; padding: 10px 14px; margin: 2px auto 14px; }
  .how li { font-size: 12px; line-height: 1.3; }
  #start-btn { padding: 11px 24px; }

/* Barra de carregamento inicial 3D */
.loader-box {
  width: 100%;
  max-width: 320px;
  margin: 10px auto 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.loader-bar {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.15);
}
#loader-fill {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #ffca3a, #ff595e);
  transition: width 0.2s ease;
}
#loader-status {
  font-size: 11px;
  color: var(--ui-dim);
  font-weight: 600;
  letter-spacing: 0.03em;
}
#start-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

  .go-panel h2 { font-size: 32px; }
  .win-panel h2 { font-size: 26px; }
  .go-panel p, .win-panel p { margin: 6px 0 14px; font-size: 13px; }
  .win-stats { gap: 10px; margin-bottom: 14px; }
  .win-stats .stat { padding: 8px 6px; }
  .win-stats .stat span { font-size: 20px; }
}

/* Retícula do conta-gotas (Fase 5a): anel fino + ponto central, no meio da tela.
   Originalmente marcava só onde o botão Pintar (🎨) amostra a cor no Camaleão —
   nasceu quando o jogo só tinha câmera em 3ª pessoa (FollowCamera). Quando o
   Caçador em 1ª pessoa chegou depois, a retícula foi reaproveitada pra mirar o
   jato de água também — e nesse caso faz sentido (a câmera fica no próprio
   olho, sem sobreposição). No Camaleão, porém, `FollowCamera.update()`
   centraliza o boneco na tela TODO frame (`camera.lookAt(pos)`) — a retícula
   sempre caía em cima do próprio personagem, parecendo uma mira nele (confuso
   pra quem está jogando ou assistindo). Escondida por padrão (Camaleão); as
   regras de modo reativam só nos casos em que a câmera não sobrepõe o boneco
   (Caçador solo e Caçador Online, 1ª pessoa nos dois). */
#reticle {
  display: none;
  position: fixed;
  left: 50%; top: 50%;
  width: 26px; height: 26px;
  margin: -13px 0 0 -13px;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35), inset 0 0 0 1px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  z-index: 5;
}
body.mode-hunter #reticle,
body.mode-online.online-hunter #reticle { display: block; }
#reticle::after {
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  width: 3px; height: 3px;
  margin: -1.5px 0 0 -1.5px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
}

/* ── Roda de cor HSV (Fase 5b) ─────────────────────────────────────────────── */
#palette-panel {
  position: absolute;
  right: max(88px, calc(env(safe-area-inset-right) + 88px));
  top: 50%;
  transform: translateY(-50%);
  z-index: 9;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: 16px;
  background: rgba(20, 24, 30, 0.82);
  border: 1.5px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  touch-action: none;
}
#palette-panel.hidden { display: none; }
.pal-wheel-wrap { position: relative; width: 150px; height: 150px; }
#pal-wheel {
  width: 150px; height: 150px;
  border-radius: 50%;
  touch-action: none;
  cursor: crosshair;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.14);
}
#pal-marker {
  position: absolute;
  width: 16px; height: 16px;
  margin: -8px 0 0 -8px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}
#pal-value {
  -webkit-appearance: none; appearance: none;
  width: 150px; height: 20px;
  border-radius: 10px;
  background: linear-gradient(90deg, #000, #fff);
  outline: none;
}
#pal-value::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; border: 2px solid rgba(0, 0, 0, 0.5);
  cursor: pointer;
}
#pal-value::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; border: 2px solid rgba(0, 0, 0, 0.5); cursor: pointer;
}
.pal-foot { display: flex; align-items: center; gap: 12px; width: 100%; }
#pal-swatch {
  flex: 1; height: 28px; border-radius: 8px;
  border: 1.5px solid rgba(255, 255, 255, 0.25);
}
#pal-close {
  pointer-events: auto;
  padding: 6px 16px; height: 28px;
  border-radius: 8px;
  border: 1.5px solid rgba(159, 232, 255, 0.7);
  background: rgba(159, 232, 255, 0.22);
  color: #eaffff; font: inherit; font-size: 13px; font-weight: 700;
  cursor: pointer;
}
#pal-close:active { transform: scale(0.95); }

/* ── Seletor de forma no menu (Fase 4) ─────────────────────────────────────── */
.body-label {
  font-size: 12px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; opacity: 0.7; margin: 4px 0 8px;
}
.body-pick { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 16px; }
.body-pick button {
  -webkit-tap-highlight-color: transparent;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  width: 76px; padding: 10px 6px;
  border-radius: 14px;
  border: 2px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.88);
  font: inherit; font-size: 12px; font-weight: 600;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.08s ease;
}
.body-pick button .bp-ic { font-size: 26px; line-height: 1; }
.body-pick button:active { transform: scale(0.96); }
.body-pick button.on {
  background: rgba(159, 232, 255, 0.2);
  border-color: rgba(159, 232, 255, 0.75);
  color: #eaffff;
}

/* ---------- Conta (Plano 2, Fase A — #auth-modal) ---------- */
/* Bug real: não existe `.hidden { display:none }` genérico neste projeto —
   cada contexto define sua própria regra escopada (`#start-overlay.hidden`,
   `.menu-modal.hidden` etc., ver o resto do arquivo). Sem isto,
   #auth-logged-in/#custom-username-logged-in ficavam com a classe `hidden`
   aplicada mas continuavam `display:block` — os dois blocos (logado/
   deslogado) apareciam empilhados ao mesmo tempo. */
#auth-logged-out.hidden,
#auth-logged-in.hidden,
#custom-username-logged-out.hidden,
#custom-username-logged-in.hidden {
  display: none;
}
#auth-chip.on {
  background: rgba(46, 204, 113, 0.22);
  border-color: rgba(46, 204, 113, 0.6);
}
.auth-tabs {
  display: flex; gap: 6px;
  background: rgba(255, 255, 255, 0.08);
  padding: 4px; border-radius: 12px;
  margin-bottom: 14px;
}
.auth-tab {
  flex: 1; font: inherit; font-size: 13px; font-weight: 700;
  padding: 8px 0; border: none; border-radius: 9px;
  background: transparent; color: var(--ui-dim);
  cursor: pointer;
}
.auth-tab.on { background: rgba(255, 255, 255, 0.16); color: #fff; }
#auth-form { display: flex; flex-direction: column; gap: 10px; }
#auth-form input {
  font: inherit; font-size: 14px;
  padding: 11px 14px; border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  outline: none;
}
#auth-form input.hidden { display: none; }
#auth-form input::placeholder { color: rgba(255, 255, 255, 0.4); }
#auth-form .btn-primary { margin-top: 4px; }
.auth-msg { font-size: 12px; margin-top: 10px; text-align: center; min-height: 15px; color: var(--ui-dim); }
.auth-msg.error { color: #ff6b6b; }
.auth-welcome { margin-bottom: 14px; font-size: 14px; }

/* Personalização (Fase D, Plano 2 — #custom-modal) */
.custom-note { font-size: 12px; color: var(--ui-dim); line-height: 1.4; }
#custom-username {
  width: 100%;
  font: inherit; font-size: 14px;
  padding: 11px 14px; border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  outline: none;
}

/* Ranking (Fase E, Plano 2 — #ranking-modal) */
.ranking-list {
  list-style: none;
  display: flex; flex-direction: column; gap: 6px;
  max-height: 320px; overflow-y: auto;
  margin-top: 14px;
}
.ranking-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
}
.ranking-rank { font-weight: 800; width: 20px; text-align: center; color: var(--accent); flex: none; }
.ranking-name { flex: 1; font-size: 13px; color: var(--ui); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ranking-value { font-size: 12px; color: var(--ui-dim); font-variant-numeric: tabular-nums; flex: none; }
.ranking-empty { text-align: center; color: var(--ui-dim); padding: 20px 0; font-size: 13px; }

/* Missões (Fase F, Plano 2 — #missions-modal) */
.missions-list {
  list-style: none;
  display: flex; flex-direction: column; gap: 10px;
  max-height: 340px; overflow-y: auto;
  margin-top: 4px;
}
.mission-row {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid transparent;
}
.mission-row.completed { background: rgba(46, 204, 113, 0.15); border-color: rgba(46, 204, 113, 0.4); }
.mission-title { font-size: 13px; font-weight: 700; color: var(--ui); }
.mission-desc { font-size: 11px; color: var(--ui-dim); margin: 3px 0 8px; line-height: 1.35; }
.mission-bar { height: 6px; border-radius: 4px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.mission-bar-fill { height: 100%; background: var(--accent); }
.mission-row.completed .mission-bar-fill { background: #2ecc71; }
.mission-progress-text { font-size: 10px; color: var(--ui-dim); text-align: right; margin-top: 3px; font-variant-numeric: tabular-nums; }

/* ── Painel de ajuste ao vivo (⚙️, ?tune=1 — TunePanel.js) ──────────────────
   Escondido por padrão (display:none) tanto no botão quanto no painel — só
   initTunePanel() os revela, e só depois de conferir a query string, então
   nunca aparecem sem o parâmetro na URL. */
#tune-btn {
  display: none;
  position: fixed;
  right: max(10px, env(safe-area-inset-right));
  bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 50;
  width: 40px; height: 40px;
  align-items: center; justify-content: center;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  background: rgba(20, 24, 30, 0.75);
  color: #fff;
  font-size: 18px;
  backdrop-filter: blur(6px);
}
#tune-btn:active { transform: scale(0.94); }

#tune-panel {
  position: fixed;
  right: max(10px, env(safe-area-inset-right));
  bottom: max(58px, calc(env(safe-area-inset-bottom) + 58px));
  z-index: 51;
  width: min(320px, calc(100vw - 20px));
  max-height: 70vh;
  overflow-y: auto;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1.5px solid rgba(255, 255, 255, 0.16);
  background: rgba(20, 24, 30, 0.9);
  color: #eef0f2;
  font-size: 12px;
  backdrop-filter: blur(8px);
}
#tune-panel.hidden { display: none; }
.tune-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px; font-size: 13px;
}
.tune-header button {
  background: none; border: none; color: #fff; font-size: 14px; padding: 2px 6px;
}
.tune-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 8px;
  align-items: center;
  margin-bottom: 8px;
}
.tune-row label { grid-column: 1 / -1; opacity: 0.85; font-size: 11px; }
.tune-row input[type="range"] { width: 100%; }
.tune-val { min-width: 34px; text-align: right; font-variant-numeric: tabular-nums; }
.tune-footer { display: flex; gap: 8px; margin: 8px 0; }
.tune-footer button {
  flex: 1;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 11px;
}
#tune-readout {
  margin: 0;
  padding: 8px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.35);
  font-size: 10px;
  line-height: 1.5;
  white-space: pre-wrap;
  user-select: text;
}

/* ══════════════════════════════════════════════════════════════════════
   Redesign do menu (mansão pintada) — 3 telas dentro de #start-overlay:
   screen-main / screen-mode / screen-loading, alternadas por src/MenuUI.js.
   Uma única ilustração (assets/menu/mansion-hall.png) + filtro CSS por
   data-screen gera as 3 variantes de fundo dos mockups.
   ══════════════════════════════════════════════════════════════════════ */

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

#start-overlay {
  display: block;
  overflow: hidden;
  padding: 0;
  background: #0c0a04; /* fallback se a ilustração não carregar */
}
#start-overlay.hidden { display: none; }

.menu-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: url('../assets/menu/mansion-hall.png') center/cover no-repeat;
  transition: filter 0.35s ease;
}
#start-overlay[data-screen="main"] .menu-bg { filter: none; }
#start-overlay[data-screen="mode"] .menu-bg { filter: brightness(0.55) saturate(0.85); }
#start-overlay[data-screen="loading"] .menu-bg { filter: brightness(0.4) saturate(0.9) blur(6px); }

#start-overlay::before {
  content: "";
  position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: linear-gradient(180deg, rgba(10, 8, 3, 0.15) 0%, rgba(8, 6, 3, 0.65) 100%);
  transition: background 0.35s ease;
}
#start-overlay[data-screen="mode"]::before {
  background: radial-gradient(120% 120% at 50% 30%, rgba(19, 26, 37, 0.4) 0%, rgba(7, 10, 15, 0.88) 100%);
}
#start-overlay[data-screen="loading"]::before { background: rgba(6, 5, 2, 0.55); }

.menu-screen {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: none;
  flex-direction: column;
  overflow-y: auto;
  padding: max(16px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right))
           max(16px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
}
.menu-screen.active { display: flex; }

/* ---------- Chrome reaproveitável (glass, no mesmo espírito do HUD) ---------- */
.glass-chip {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  border: 1.5px solid rgba(255, 255, 255, 0.4);
  backdrop-filter: blur(8px) saturate(180%);
  -webkit-backdrop-filter: blur(8px) saturate(180%);
  color: #fff;
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex: none;
}
.glass-chip:active { transform: scale(0.93); }
.glass-chip-text {
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  backdrop-filter: blur(8px) saturate(180%);
  -webkit-backdrop-filter: blur(8px) saturate(180%);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.glass-chip-text:active { transform: scale(0.96); }

/* ---------- Tela 1: Menu principal ---------- */
.menu-topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
/* Altura fixa (não largura) — a logo é um lockup bem mais "quadrado" que o
   antigo <h1> de texto; controlar por largura deixava a topbar alta demais e
   empurrava o resto da tela (chegava a sobrepor o JOGAR em telas baixas). */
.menu-logo-img {
  display: block;
  height: 48px;
  width: auto;
  max-width: 46vw;
  filter: drop-shadow(0 3px 18px rgba(0, 0, 0, 0.55)) drop-shadow(0 0 30px rgba(255, 190, 90, 0.2));
}
.menu-tagline {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.82);
  margin-top: 2px;
}
.menu-top-right { display: flex; gap: 8px; }

/* Faixa central: única flex row entre a topbar e a nav — nenhum dos 3 filhos
   pode colidir com topbar/nav porque a caixa da faixa termina antes deles;
   `overflow:hidden` evita que a lista lateral, se ficar alta demais num
   viewport curto, vaze por cima da topbar em vez de simplesmente cortar. */
.menu-hero {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.menu-character-deco {
  position: absolute;
  right: 4%;
  bottom: 0;
  width: min(16vw, 150px);
  max-height: 90%;
  object-fit: contain;
  filter: drop-shadow(0 12px 20px rgba(0, 0, 0, 0.4));
  pointer-events: none;
}

.menu-play-btn {
  position: relative;
  z-index: 1;
  flex: none;
  font: inherit;
  font-weight: 900;
  font-size: 20px;
  letter-spacing: 0.02em;
  color: #402c00;
  background: linear-gradient(180deg, #ffd84a, #ffb703);
  border: none;
  padding: 16px 54px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(255, 183, 3, 0.45), inset 0 2px 0 rgba(255, 255, 255, 0.5);
}
.menu-play-btn:active { transform: translateY(2px) scale(0.98); }

.menu-side-list {
  position: absolute;
  left: 4%;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  width: min(230px, 38vw);
  max-height: 100%;
  overflow: hidden;
}
.menu-list-row {
  display: flex; align-items: center; gap: 10px;
  text-align: left;
  padding: 7px 12px;
  border-radius: 12px;
  background: rgba(10, 10, 14, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #fff;
  cursor: pointer;
  flex: none;
}
.menu-list-row:active { background: rgba(10, 10, 14, 0.62); }
.menu-list-row:disabled { opacity: 0.45; cursor: default; }
.menu-list-row:disabled:active { background: rgba(10, 10, 14, 0.42); }
.mlr-ic { font-size: 18px; flex: none; }
.mlr-txt { display: flex; flex-direction: column; }
.mlr-txt b { font-size: 12px; }
.mlr-txt small { font-size: 10px; color: rgba(255, 255, 255, 0.65); }

/* Filho de fluxo normal (não mais absoluto): cola no rodapé do #screen-main
   naturalmente, por ser o último item do flex column, sem risco de sobrepor
   a faixa central mesmo quando ela precisa de mais altura. */
.menu-bottom-nav {
  flex: none;
  align-self: center;
  display: flex; gap: 6px;
  margin-top: 4px;
}
.menu-bottom-nav button {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  min-width: 70px;
  padding: 9px 8px;
  border-radius: 12px;
  background: rgba(10, 10, 14, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: rgba(255, 255, 255, 0.85);
  font-size: 9.5px; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase;
  cursor: pointer;
}
.menu-bottom-nav .bn-ic { font-size: 19px; }
.menu-bottom-nav button:active { background: rgba(10, 10, 14, 0.62); }

.menu-version {
  position: absolute;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(10px, env(safe-area-inset-bottom));
  font-size: 10px;
  color: rgba(255, 255, 255, 0.55);
  z-index: 2;
}

/* ---------- Tela 2: Escolha de modo ---------- */
.menu-topbar-mode { justify-content: space-between; }

.mode-title {
  text-align: center;
  font-size: 26px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 3px 16px rgba(0, 0, 0, 0.6);
  margin: 6px 0 2px;
}
.mode-subtitle {
  text-align: center;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.75);
  line-height: 1.4;
  margin: 0 0 14px;
}

.mode-cards {
  /* min-height evita que o flex:1 esprema os cards abaixo do que o conteúdo
     precisa em telas baixas — nesse caso quem rola é #screen-mode
     (overflow-y:auto em .menu-screen), em vez do texto vazar por cima da
     barra inferior (era o que acontecia só com flex:1, sem piso de altura). */
  flex: 1;
  min-height: 190px;
  display: flex;
  gap: 14px;
  align-items: stretch;
  justify-content: center;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding: 4px 2px 8px;
}
.mode-card {
  scroll-snap-align: center;
  flex: 1 1 0;
  min-width: 200px;
  max-width: 300px;
  min-height: 0; /* permite o próprio card rolar em vez de estourar, ver overflow-y abaixo */
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 16px;
  border-radius: 24px;
  text-align: center;
  color: #fff;
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1.5px solid transparent;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.mode-card:active { transform: scale(0.97); }
.mode-card.on { border-color: rgba(255, 255, 255, 0.7); box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.25); }

.mode-card-chameleon { background: linear-gradient(180deg, rgba(46, 196, 182, 0.32), rgba(46, 196, 182, 0.12)); border-color: rgba(46, 196, 182, 0.5); }
.mode-card-hunter    { background: linear-gradient(180deg, rgba(58, 134, 255, 0.32), rgba(58, 134, 255, 0.12)); border-color: rgba(58, 134, 255, 0.5); }
.mode-card-online    { background: linear-gradient(180deg, rgba(155, 89, 182, 0.32), rgba(155, 89, 182, 0.12)); border-color: rgba(155, 89, 182, 0.5); }

.mc-badge {
  font-size: 10px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 3px 10px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
}
.mc-title { font-size: 20px; font-weight: 900; }
.mc-desc { font-size: 11px; line-height: 1.4; color: rgba(255, 255, 255, 0.85); min-height: 44px; }
.mc-cta {
  margin-top: auto;
  font-size: 12px; font-weight: 800;
  padding: 9px 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: #10131a;
}
.mode-card-chameleon .mc-cta { color: #0d3d38; }
.mode-card-hunter .mc-cta { color: #0d2a52; }
.mode-card-online .mc-cta { color: #34104a; }

.mode-bottom-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.mode-back-btn {
  font: inherit; font-weight: 700; font-size: 12px;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 9px 16px;
  border-radius: 10px;
  cursor: pointer;
}
.mode-room-note {
  flex: 1;
  min-width: 200px;
  font-size: 11px;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.8);
  text-align: center;
}
.mode-tip {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.85);
  background: rgba(10, 10, 14, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  padding: 8px 12px;
  max-width: 240px;
}

/* ---------- Tela 3: Carregamento ---------- */
.loading-logo { text-align: center; margin-top: 6px; }
.loading-logo-img {
  margin: 0 auto;
  width: min(46vw, 210px);
}

.loading-character {
  width: min(30vw, 190px);
  margin: 6px auto;
  filter: drop-shadow(0 12px 20px rgba(0, 0, 0, 0.45));
}

#screen-loading .loader-box {
  width: min(420px, 84vw);
  margin: 4px auto 10px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.loader-caption {
  font-size: 12px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase;
  color: #fff;
}
#screen-loading .loader-bar {
  width: 100%; height: 10px;
  background: rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
}
#screen-loading #loader-fill {
  display: block; height: 100%; width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #2ec4b6, #cde05a);
  transition: width 0.2s ease;
}
#screen-loading #loader-status {
  font-size: 12px; font-weight: 700; color: rgba(255, 255, 255, 0.85);
}

.loading-stages {
  display: flex; justify-content: center; gap: 14px;
  margin: 4px 0 8px;
  flex-wrap: wrap;
}
.stage-ic {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-size: 20px;
  opacity: 0.35;
  transition: opacity 0.2s ease;
}
.stage-ic small { font-size: 8px; font-weight: 700; color: rgba(255, 255, 255, 0.8); max-width: 64px; text-align: center; }
.stage-ic.active { opacity: 1; }

.loading-tip {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  max-width: 220px;
  font-size: 11px;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.9);
  background: rgba(10, 10, 14, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  padding: 8px 12px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.loading-tip b { color: var(--accent); }
.loading-tip-left { left: max(16px, env(safe-area-inset-left)); }
.loading-tip-right { right: max(16px, env(safe-area-inset-right)); }

/* #screen-loading usa .menu-version em fluxo normal (não mais o canto absoluto
   de screen-main/mode) — senão sobrepõe a última linha de .loading-stages em
   telas baixas, onde a tela já é naturalmente mais cheia de elementos. */
#screen-loading .menu-version {
  position: static;
  display: block;
  text-align: center;
  margin-top: auto;
  padding-top: 6px;
}

/* ---------- Modais (Configurações / Como Jogar / Em breve) ---------- */
.menu-modal {
  position: absolute; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background: rgba(4, 4, 6, 0.6);
  backdrop-filter: blur(3px);
}
.menu-modal.hidden { display: none; }
.menu-modal-card {
  width: min(420px, 100%);
  max-height: 84vh;
  overflow-y: auto;
  padding: 20px;
  border-radius: 18px;
  background: rgba(18, 16, 10, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--ui);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.menu-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.menu-modal-head h3 { font-size: 16px; }
.modal-close {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
  flex: none;
}
.soon-card { text-align: center; }
.soon-card h3 { margin-bottom: 6px; }
.soon-card p { color: var(--ui-dim); margin-bottom: 16px; }

/* ---------- Responsivo ---------- */
@media (max-width: 720px) {
  .menu-logo-img { height: 36px; }
  .menu-character-deco { display: none; } /* evita competir com o layout apertado */
  /* DICA/LEMBRE-SE são ancoradas nos cantos superiores e colidem com o título
     centralizado da tela de loading abaixo de ~720px — somem, o conteúdo
     essencial (barra de progresso, estágios) continua intacto. */
  .loading-tip { display: none; }
}
/* Abaixo disso a lista lateral chegaria perto demais do botão JOGAR
   centralizado. Some só o item ainda placeholder (Instalar Aplicativo,
   [data-soon] — Fase C do Plano 2) — "Como Jogar" e "Continuar Partida"
   (funções reais) ficam, pra não depender só da tela de Escolha de Modo. */
@media (max-width: 480px) {
  .menu-side-list .menu-list-row[data-soon] { display: none; }
  /* Só sobrou 1 linha (Como Jogar), mas ancorada à esquerda + JOGAR
     centralizado ainda colidiam horizontalmente em telas bem estreitas.
     Empilha os dois em coluna dentro do hero — layout real em vez de
     posicionamento absoluto "no chute" — pra garantir zero sobreposição. */
  .menu-hero { flex-direction: column; gap: 10px; }
  .menu-side-list {
    position: static;
    transform: none;
    width: auto;
    align-items: center;
  }
}
@media (max-height: 420px) {
  .menu-play-btn { padding: 12px 40px; font-size: 16px; }
  .mode-title { font-size: 20px; margin-top: 0; }
  .mode-card { padding: 14px 12px; min-width: 170px; }
  .mc-desc { min-height: 0; }
  .loading-character { width: min(20vw, 110px); }
}
