*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  width: 100%; height: 100%;
  background: #0b0d10;
  color: #f5f5f5;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

#stage {
  position: fixed;
  inset: 0;
  display: block;
}

/* Canvas do humanoide — pode ser o #viewport legado ou o canvas criado
   pelo HumanoidPlayer.mount(#stage). Ambos ficam no fundo, cobrindo o
   stage inteiro, atrás do HUD e do botão. */
#stage > canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  z-index: 1;
}

#hud {
  position: absolute;
  top: env(safe-area-inset-top, 0);
  left: 0; right: 0;
  padding: 24px 20px 16px;
  text-align: center;
  pointer-events: none;
  z-index: 2;
  background: linear-gradient(to bottom, rgba(0,0,0,0.35), transparent);
}

#character-name {
  font-size: 20px;
  font-weight: 500;
  letter-spacing: 0.02em;
  margin: 0;
}

#speak {
  position: absolute;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0) + 32px);
  transform: translateX(-50%);
  width: 128px;
  height: 128px;
  border-radius: 50%;
  border: none;
  background: #f5f5f5;
  color: transparent;
  cursor: pointer;
  z-index: 3;
  box-shadow:
    0 0 0 6px rgba(245, 245, 245, 0.12),
    0 12px 40px rgba(0, 0, 0, 0.6);
  transition: transform 120ms ease, box-shadow 120ms ease;
  touch-action: manipulation;
}

#speak:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#speak:not(:disabled):active,
#speak.active {
  transform: translateX(-50%) scale(0.92);
  box-shadow:
    0 0 0 12px rgba(245, 245, 245, 0.2),
    0 8px 24px rgba(0, 0, 0, 0.6);
}

/* thinking: aro pulsando enquanto o server processa STT+TTS. */
#speak.thinking {
  background: #cfd6df;
  animation: speak-pulse 1.1s ease-in-out infinite;
}

/* speaking: aro em tom quente enquanto o áudio de resposta toca. */
#speak.speaking {
  background: #ffd28a;
  box-shadow:
    0 0 0 12px rgba(255, 210, 138, 0.28),
    0 8px 24px rgba(0, 0, 0, 0.6);
}

@keyframes speak-pulse {
  0%, 100% { box-shadow: 0 0 0 6px rgba(245,245,245,0.12), 0 12px 40px rgba(0,0,0,0.6); }
  50%      { box-shadow: 0 0 0 16px rgba(245,245,245,0.24), 0 12px 40px rgba(0,0,0,0.6); }
}

.speak-inner {
  display: block;
  width: 44px;
  height: 44px;
  margin: 42px auto 0;
  border-radius: 50%;
  background: #0b0d10;
}

#status {
  position: absolute;
  bottom: calc(env(safe-area-inset-bottom, 0) + 180px);
  left: 20px; right: 20px;
  text-align: center;
  font-size: 14px;
  color: rgba(245, 245, 245, 0.7);
  min-height: 20px;
  pointer-events: none;
  z-index: 2;
}
