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

:root {
  --fundo: #08080c;
  --superficie: #101018;
  --superficie-2: #1a1a26;
  --borda: #26263a;
  --texto: #ededf5;
  --secundario: #9a9ab0;
  --azul: #2563eb;
  --esmeralda: #10b981;
  --violeta: #7c3aed;
  --ambar: #f59e0b;
  --vermelho: #ef4444;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--fundo);
  color: var(--texto);
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
}

.jogo {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

.cena3d {
  position: absolute;
  inset: 0;
}

.cena3d canvas {
  display: block;
  touch-action: none;
}

/* ============================== OVERLAYS / TELAS ============================== */

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: radial-gradient(circle at 50% 35%, rgba(8, 8, 12, 0.55) 0%, rgba(8, 8, 12, 0.86) 70%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 100;
  overflow-y: auto;
}

.overlay.ativo {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: linear-gradient(160deg, var(--superficie) 0%, var(--superficie-2) 100%);
  border: 1px solid var(--borda);
  border-radius: 22px;
  padding: 2.5rem 2rem;
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(16, 185, 129, 0.06);
  animation: entrarModal 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-pequeno {
  max-width: 340px;
  text-align: center;
}

@keyframes entrarModal {
  from {
    opacity: 0;
    transform: translateY(-16px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal h1 {
  font-size: clamp(1.9rem, 5vw, 2.5rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.4rem;
  background: linear-gradient(135deg, var(--esmeralda), var(--azul));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.modal h2 {
  font-size: 1.1rem;
  font-weight: 650;
  margin-bottom: 0.6rem;
  color: var(--texto);
}

.subtitulo {
  color: var(--secundario);
  font-size: 1rem;
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

.bloco {
  margin: 1.25rem 0;
  padding: 1rem 1.1rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--borda);
}

.bloco p {
  color: var(--secundario);
  font-size: 0.94rem;
  line-height: 1.6;
}

.bloco strong {
  color: var(--texto);
}

.bloco-formula {
  border-color: rgba(16, 185, 129, 0.3);
  background: rgba(16, 185, 129, 0.06);
  font-size: 0.92rem;
  line-height: 1.65;
  color: var(--secundario);
}

.bloco-formula strong {
  color: var(--esmeralda);
}

.lista-controles {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  color: var(--texto);
  font-size: 0.92rem;
}

.chip {
  display: inline-block;
  background: var(--superficie-2);
  border: 1px solid var(--borda);
  border-radius: 999px;
  padding: 0.15rem 0.65rem;
  margin-right: 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--esmeralda);
}

.detalhe {
  color: var(--secundario);
  font-size: 0.88rem;
  line-height: 1.55;
}

.placar {
  display: flex;
  gap: 2rem;
  justify-content: center;
  margin: 1.5rem 0;
}

.placar-item .etiqueta {
  color: var(--secundario);
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
  text-align: center;
}

.placar-item .valor {
  font-size: 2.3rem;
  font-weight: 700;
  color: var(--esmeralda);
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.estatisticas {
  color: var(--secundario);
  font-size: 0.86rem;
  text-align: center;
  line-height: 1.6;
  margin-bottom: 1rem;
}

.moral {
  background: rgba(16, 185, 129, 0.08);
  border-left: 3px solid var(--esmeralda);
  padding: 0.9rem 1rem;
  border-radius: 8px;
  margin: 1.25rem 0;
  color: var(--texto);
  font-style: italic;
  font-size: 0.92rem;
  line-height: 1.55;
}

/* ============================== BOTÕES ============================== */

.botao-primario,
.botao-secundario,
.botao-perigo {
  width: 100%;
  padding: 0.9rem 1.5rem;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 650;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, opacity 0.16s ease;
  font-family: inherit;
  margin-top: 0.75rem;
  touch-action: manipulation;
}

.botao-primario {
  background: linear-gradient(135deg, var(--esmeralda), #0d9467);
  color: #04140f;
}

.botao-primario:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(16, 185, 129, 0.28);
}

.botao-primario:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.botao-secundario {
  background: transparent;
  color: var(--texto);
  border: 1px solid var(--borda);
}

.botao-secundario:hover {
  background: rgba(255, 255, 255, 0.06);
}

.botao-perigo {
  background: linear-gradient(135deg, var(--vermelho), #b91c1c);
  color: #fff;
}

.botao-perigo:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(239, 68, 68, 0.3);
}

button:focus-visible {
  outline: 2px solid var(--esmeralda);
  outline-offset: 2px;
}

.botao-icone {
  width: 3rem;
  height: 3rem;
  min-width: 3rem;
  border-radius: 12px;
  border: 1px solid var(--borda);
  background: rgba(8, 8, 12, 0.7);
  color: var(--texto);
  font-size: 0.9rem;
  cursor: pointer;
  touch-action: manipulation;
}

.botao-icone:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* ============================== HUD ============================== */

.hud {
  position: absolute;
  inset: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 50;
}

.hud.visivel {
  opacity: 1;
  pointer-events: none; /* os cliques passam para o canvas; só os controles internos capturam */
}

.hud.visivel .stat,
.hud.visivel button,
.hud.visivel .hud-satisfacao,
.hud.visivel .legenda {
  pointer-events: auto;
}

.hud-linha {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: center;
}

.hud-topo {
  justify-content: flex-start;
}

.stat {
  background: rgba(8, 8, 12, 0.72);
  border: 1px solid var(--borda);
  border-radius: 12px;
  padding: 0.5rem 0.85rem;
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 5.2rem;
}

.stat-pequeno {
  min-width: 4.4rem;
  padding: 0.4rem 0.65rem;
}

.stat .label {
  color: var(--secundario);
  font-size: 0.68rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat .valor {
  color: var(--texto);
  font-size: 1.15rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.valor.esmeralda {
  color: var(--esmeralda);
}

.valor.vermelho {
  color: var(--vermelho);
}

.hud-satisfacao {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: rgba(8, 8, 12, 0.72);
  border: 1px solid var(--borda);
  border-radius: 12px;
  padding: 0.5rem 0.85rem;
  backdrop-filter: blur(10px);
  max-width: 26rem;
}

.hud-satisfacao .label {
  color: var(--secundario);
  font-size: 0.7rem;
  font-weight: 650;
  text-transform: uppercase;
  white-space: nowrap;
}

.barra-fundo {
  flex: 1;
  height: 0.55rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.barra-preenchimento {
  height: 100%;
  width: 100%;
  background: var(--esmeralda);
  transition: width 0.25s ease, background 0.25s ease;
}

.hud-satisfacao .valor {
  font-size: 0.9rem;
  font-weight: 700;
  min-width: 3rem;
  text-align: right;
}

.hud-estatisticas {
  justify-content: flex-start;
}

.hud-rodape {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.legenda {
  display: flex;
  gap: 0.75rem;
  background: rgba(8, 8, 12, 0.72);
  border: 1px solid var(--borda);
  border-radius: 12px;
  padding: 0.5rem 0.85rem;
  backdrop-filter: blur(10px);
  flex-wrap: wrap;
}

.legenda-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--secundario);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.ponto {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  display: inline-block;
}

.ponto.esmeralda {
  background: var(--esmeralda);
}

.ponto.ambar {
  background: var(--ambar);
}

.ponto.vermelho {
  background: var(--vermelho);
}

.botao-rodada {
  width: auto;
  min-width: 12rem;
  margin-top: 0;
}

.botao-rodada.destaque {
  animation: pulsarBotao 1.6s ease-in-out infinite;
}

@keyframes pulsarBotao {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.45);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(16, 185, 129, 0);
  }
}

/* ============================== DICA / TOOLTIP / TOAST ============================== */

.dica {
  /* Ancorada pela base do viewport (não pelo topo): o número de linhas do HUD
     no topo varia com o conteúdo (rodada/orçamento/satisfação/estatísticas) e
     é imprevisível de antemão, então um "top" fixo sempre corria o risco de
     cair por cima de alguma stat — em telas largas isso realmente acontecia
     (a dica cobria a stat de Pontuação e o botão de pausa). Ancorar pela base
     evita prever a altura variável do topo, tanto no desktop quanto no mobile. */
  position: absolute;
  bottom: 8rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(8, 8, 12, 0.78);
  border: 1px solid var(--borda);
  border-radius: 999px;
  padding: 0.55rem 1.1rem;
  font-size: 0.82rem;
  color: var(--secundario);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
  z-index: 60;
  text-align: center;
  max-width: 90vw;
}

.dica.visivel {
  opacity: 1;
}

.tooltip {
  position: fixed;
  background: rgba(8, 8, 12, 0.92);
  border: 1px solid var(--borda);
  border-radius: 10px;
  padding: 0.55rem 0.8rem;
  font-size: 0.82rem;
  color: var(--texto);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 70;
  max-width: 15rem;
}

.tooltip.visivel {
  opacity: 1;
}

.tooltip strong {
  color: var(--esmeralda);
  font-size: 0.85rem;
}

.tooltip span {
  color: var(--secundario);
}

.toast {
  position: absolute;
  bottom: 5.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(16, 24, 20, 0.92);
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: 999px;
  padding: 0.6rem 1.2rem;
  font-size: 0.85rem;
  color: var(--texto);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 80;
  text-align: center;
  max-width: 90vw;
}

.toast.visivel {
  opacity: 1;
  transform: translateX(-50%) translateY(-4px);
}

/* ============================== CONFIRMAÇÃO DE REMOÇÃO ============================== */

.confirm {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 8, 12, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 90;
  padding: 1.5rem;
}

.confirm.ativo {
  opacity: 1;
  pointer-events: auto;
}

.confirm-caixa {
  background: var(--superficie);
  border: 1px solid var(--borda);
  border-radius: 16px;
  padding: 1.5rem;
  max-width: 22rem;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.confirm-caixa p {
  color: var(--texto);
  font-size: 0.94rem;
  line-height: 1.5;
  margin-bottom: 0.5rem;
}

.confirm-botoes {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.75rem;
}

.confirm-botoes button {
  margin-top: 0;
}

/* ============================== RESPONSIVO ============================== */

@media (max-width: 640px) {
  .modal {
    padding: 1.75rem 1.25rem;
    border-radius: 18px;
  }

  .hud {
    top: 0.5rem;
    left: 0.5rem;
    right: 0.5rem;
  }

  .stat {
    min-width: 4.4rem;
    padding: 0.4rem 0.6rem;
  }

  .stat .valor {
    font-size: 1rem;
  }

  .hud-satisfacao {
    max-width: none;
  }

  .hud-rodape {
    flex-direction: column;
    align-items: stretch;
  }

  .legenda {
    justify-content: center;
  }

  .botao-rodada {
    width: 100%;
    min-width: 0;
  }

  .placar {
    gap: 1.25rem;
  }

  .placar-item .valor {
    font-size: 1.9rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
